Skip to content

Instantly share code, notes, and snippets.

@cyberlex404
Created January 17, 2018 11:50
Show Gist options
  • Select an option

  • Save cyberlex404/50587d7a180d26bd2bb2cd4990111bf3 to your computer and use it in GitHub Desktop.

Select an option

Save cyberlex404/50587d7a180d26bd2bb2cd4990111bf3 to your computer and use it in GitHub Desktop.
<?php
/**
* Created by PhpStorm.
* User: Lex
* Date: 18.03.2015
* Time: 14:13
*/
/**
* Implements hook_rules_action_info().
*/
function request_rules_action_info() {
$actions = array(
'request_mass_sender' => array(
'label' => 'Mass sender: Отправить письмо с заявками',
'group' => t('Request'),
'parameter' => array(
// To select a user role.
'user' => array(
'type' => 'user',
'label' => t('User'),
'description' => 'Учётная запись клиента',
),
'start_rid' => array(
'type' => 'integer',
'label' => t('Start RID'),
'description' => 'RID начальной заявки',
),
'end_rid' => array(
'type' => 'integer',
'label' => t('End RID'),
'description' => 'RID последней заявки',
),
),
'provides' => array(
'success' =>array(
'label' => t('success'),
'type' => 'integer',
),
)
),
'request_set_last_rid' => array(
'label' => 'Set last RID',
'group' => t('Request'),
'parameter' => array(
// To select a user role.
'request' => array(
'type' => 'integer',
'label' => t('RID'),
'description' => 'RID последней заявки',
),
),
),
'request_get_last_rid' => array(
'label' => t('Get last RID'),
'group' => t('Request'),
'provides' => array(
'rid' =>array(
'label' => t('RID'),
'type' => 'integer',
),
),
),
'request_get_request_list' => array(
'label' => t('Get request'),
'group' => t('Request'),
'provides' => array(
'rids' =>array(
'label' => t('RIDs array'),
'type' => 'list<integer>',
),
'last' =>array(
'label' => t('last RID'),
'type' => 'integer',
),
),
),
'request_send_mail' => array(
'label' => 'Отправить письмо с заявками',
'group' => t('Request'),
'parameter' => array(
// To select a user role.
'user' => array(
'type' => 'user',
'label' => t('User'),
'description' => 'Учётная запись клиента',
),
),
),
'request_send_on_list' => array(
'label' => 'Отправить письмо с заявками (ручной список)',
'group' => t('Request'),
'parameter' => array(
// To select a user role.
'user' => array(
'type' => 'user',
'label' => t('User'),
'description' => 'Учётная запись клиента',
),
'request' => array(
'type' => 'list<integer>',
'label' => t('Request'),
'description' => 'Список заявок',
),
),
'provides' => array(
'success' =>array(
'label' => t('success'),
'type' => 'integer',
),
),
),
);
return $actions;
}
function request_set_last_rid($request) {
//dpm($request);
variable_set('request_last_rid',$request);
}
function request_get_last_rid() {
$rid = variable_get('request_last_rid');
return array(
'file' => $rid,
);
}
function request_send_mail($user) {
request_send_client($user);
}
function request_mass_sender($user, $start_rid, $end_rid) {
$success = request_mass_send_client($user, $start_rid, $end_rid);
variable_set('request_last_rid_nosend', 0);
return array(
'success' => $success,
);
}
function request_send_on_list($user, $request) {
$success = request_send_client_request($user, $request);
return array(
'success' => $success,
);
}
function request_get_request_list() {
// variable_set('request_last_no_send', 8050);
// variable_set('request_last_rid', 8019);
$request = request_db_load();
$last = max($request);
dpm(max($request), 'last id');
return array(
'rids' => $request,
'last' => $last,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment