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
<?php | |
// получаем объект пользователя по id [ если нужно по имени то меняем на array('username' => 'Иван') ] | |
$user = $modx->getObject('modUser', array('id' => 2)); | |
// если пользователь существует | |
if (is_object($user)) { | |
//получаем группу поимени | |
$group = $modx->getObject('modUserGroup', array('name' => 'Users')); | |
// создаем объект прав доступа пользователя | |
$groupMember = $modx->newObject('modUserGroupMember'); |
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
<?php | |
$policy_name = 'Users'; // Имя группы пользователей | |
$policy_data = '{"load":true,"list":true,"view":true,"save":true,"remove":true,"copy":true,"view_unpublished":false}'; | |
$role_rank = 9999; | |
// Создаем новый шаблон политики доступа | |
$policy = $modx->newObject('modAccessPolicy'); | |
$policy->fromArray(array( | |
'name' => $policy_name, | |
'description' => 'User access control', |
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
{'!AjaxForm' | snippet : [ | |
'snippet' => 'FormIt', | |
'form' => '@FILE chunks/callback.tpl', | |
'hooks' => 'spam,email,FormItSaveForm', | |
'frontend_js' => 'assets/libs/ajaxform-sweetalert/js/sweetalert.js', | |
'frontend_css' => 'assets/libs/ajaxform-sweetalert/css/sweetalert.css', | |
'emailSubject' => 'Сообщение из формы обратной связи', | |
'emailTo' => 1 | resource : 'email', | |
'validationErrorMessage' => 'В форме содержатся ошибки!', | |
'successMessage' => 'Сообщение успешно отправлено' |
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
<?php | |
$q = $modx->newQuery('modUser'); | |
$q->innerJoin('modUserProfile', 'Profile'); | |
$q->limit(0); | |
$q->select(array( | |
"Profile.*", | |
"modUser.*", | |
)); | |
$s = $q->prepare(); | |
$s->execute(); |
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
<?php | |
ini_set("max_execution_time", 0); | |
ignore_user_abort(true); | |
$current_prefix = $modx->config['table_prefix']; | |
function randPrefix($size) { | |
$chars="qazxswedcvfrtgbnhyujmkiolp1234567890QAZXSWEDCVFRTGBNHYUJMKIOLP"; | |
$out_prefix=null; | |
while($size--) $out_prefix.=$chars[rand(0,StrLen($chars)-1)]; | |
return $out_prefix; | |
} |
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
<?php | |
if (!$modx->user->hasSessionContext('mgr') || !$modx->user->isMember('Administrator')) return; | |
switch ($modx->event->name) { | |
case 'OnWebPagePrerender': | |
if (!$modx->resource->get('template')) break; | |
$frontendManager = $modx->getService('frontendmanager','frontendManager', MODX_CORE_PATH . 'components/frontendmanager/model/frontendmanager/', array()); | |
if(!$frontendManager) return; | |
$modx->resource->_output .= $frontendManager->initialize($modx->context->key); | |
break; | |
case 'OnBeforeManagerPageInit': |
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
<?php | |
header("Content-type: image/jpeg"); // указываем на тип передаваемых данных | |
$root_dir = __DIR__; // корневая папка | |
$img = $root_dir."/nakl.png"; // указываем картинку фона PNG | |
$font = $root_dir."/ff.ttf"; // подрубаем шрифт | |
$font_size = 140; // размер шрифта | |
$center_w = 220; // отступ слева | |
$center_h = 680; // отступ справа |
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
<?php | |
$id_order = 9999; // id заказа который нужно удалить | |
$order = $modx->getObject('msOrder', $id_order); | |
$order->remove(); |
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
AuthName "Need authorization" | |
AuthType Basic | |
AuthUserFile /home/www/name/.htpasswd | |
require valid-user | |
#AuthUserFile /home/www/name/.htapsswd | |
#AuthName "Private access" | |
#AuthType Basic | |
#<FilesMatch "name.txt"> |
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
<?php | |
/*define('MODX_API_MODE', true); | |
require_once dirname(dirname(__FILE__)) . '/index.php'; | |
$modx->getService('error','error.modError'); | |
$modx->setLogLevel(modX::LOG_LEVEL_ERROR); | |
$modx->setLogTarget('FILE');*/ | |
$NAME = 'manager'; |