/**
  * update settings
  */
 public static function updateSetting()
 {
     $s = [['key' => 'title', 'value' => 'Yii2 Skeleton', 'title' => 'Title', 'description' => 'Homepage title', 'group' => 'General', 'type' => 'textInput', 'data' => '[]', 'default' => 'Yii2 Skeleton', 'rules' => json_encode(['required' => []])], ['key' => 'keywords', 'value' => 'Yii2, Skeleton', 'title' => 'Keywords', 'description' => 'Homepage keywords', 'group' => 'General', 'type' => 'textInput', 'data' => '[]', 'default' => 'Yii2, Skeleton', 'rules' => json_encode(['required' => []])], ['key' => 'description', 'value' => 'Skeleton for Yii Framework', 'title' => 'Description', 'description' => 'Homepage description', 'group' => 'General', 'type' => 'textInput', 'data' => '[]', 'default' => 'Skeleton for Yii Framework', 'rules' => json_encode(['required' => []])], ['key' => 'language', 'value' => 'en-US', 'title' => 'Language', 'description' => 'Site language', 'group' => 'General', 'type' => 'dropDownList', 'data' => '{LOCALE}', 'default' => 'en-US', 'rules' => json_encode(['required' => []])], ['key' => 'timezone', 'value' => 'Asia/Ho_Chi_Minh', 'title' => 'Timezone', 'description' => 'Server Timezone', 'group' => 'General', 'type' => 'dropDownList', 'data' => '{TIMEZONE}', 'default' => 'Asia/Ho_Chi_Minh', 'rules' => json_encode(['required' => []])], ['key' => 'maxNameChange', 'value' => '1', 'title' => 'Max Name Change', 'description' => 'Max name change allowed', 'group' => 'Account', 'type' => 'textInput', 'data' => '[]', 'default' => '1', 'rules' => json_encode(['required' => [], 'number' => ['min' => -1]])], ['key' => 'tokenExpiryTime', 'value' => '3600', 'title' => 'Token Expiry Time', 'description' => 'Expiration time in seconds', 'group' => 'Account', 'type' => 'textInput', 'data' => '[]', 'default' => '3600', 'rules' => json_encode(['required' => [], 'number' => ['min' => 3600]])], ['key' => 'rememberMeDuration', 'value' => '2592000', 'title' => 'Remember Me Duration', 'description' => 'Customize the duration of the Remember Me in seconds', 'group' => 'Account', 'type' => 'textInput', 'data' => '[]', 'default' => '2592000', 'rules' => json_encode(['required' => [], 'number' => ['min' => 86400]])], ['key' => 'blogTitle', 'value' => 'My Blog', 'title' => 'Title', 'description' => 'Blog page title', 'group' => 'Blog', 'type' => 'textInput', 'data' => json_encode(Core::getYesNoOption()), 'default' => 'My Blog', 'rules' => json_encode(['required' => []])], ['key' => 'blogDesc', 'value' => 'Welcome to my world.', 'title' => 'Description', 'description' => 'Blog page description', 'group' => 'Blog', 'type' => 'textInput', 'data' => json_encode(Core::getYesNoOption()), 'default' => 'Welcome to my world.', 'rules' => json_encode(['required' => []])], ['key' => 'blogKeywords', 'value' => 'blog, my blog', 'title' => 'Keywords', 'description' => 'Blog page keywords', 'group' => 'Blog', 'type' => 'textInput', 'data' => json_encode(Core::getYesNoOption()), 'default' => 'blog, my blog', 'rules' => json_encode(['required' => []])], ['key' => 'blogThumbnail', 'value' => '', 'title' => 'Thumbnail Image', 'description' => 'Blog page thumbnail', 'group' => 'Blog', 'type' => 'textInput', 'data' => json_encode(Core::getYesNoOption()), 'default' => '', 'rules' => json_encode(['url' => []])], ['key' => 'outgoingMail', 'value' => '*****@*****.**', 'title' => 'Outgoing Mail', 'description' => 'Outgoing email address', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['required' => [], 'email' => []])], ['key' => 'mailProtocol', 'value' => 'php', 'title' => 'Mail Protocol', 'description' => 'Outgoing email protocol', 'group' => 'Mail', 'type' => 'dropDownList', 'data' => json_encode(['php' => 'php', 'smtp' => 'smtp']), 'default' => 'php', 'rules' => json_encode(['required' => []])], ['key' => 'smtpHost', 'value' => '', 'title' => 'SMTP Host', 'description' => 'SMTP host', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'smtpUsername', 'value' => '', 'title' => 'SMTP Username', 'description' => 'SMTP username', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'smtpPassword', 'value' => '', 'title' => 'SMTP Password', 'description' => 'SMTP password', 'group' => 'Mail', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'smtpPort', 'value' => '', 'title' => 'SMTP Port', 'description' => 'SMTP port', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => '25', 'rules' => json_encode(['safe' => [], 'number' => []])], ['key' => 'smtpEncryption', 'value' => '', 'title' => 'SMTP Encryption', 'description' => 'SMTP Encryption', 'group' => 'Mail', 'type' => 'textInput', 'data' => '[]', 'default' => 'ssl', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'fbPageUrl', 'value' => '', 'title' => 'Facebook Page URL', 'description' => 'Facebook Page URL', 'group' => 'Social', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'url' => []])], ['key' => 'fbAppId', 'value' => '', 'title' => 'Facebook App ID', 'description' => 'Facebook App ID', 'group' => 'Social', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'fbAdmins', 'value' => '', 'title' => 'Facebook Admins', 'description' => 'Facebook Admins ID', 'group' => 'Social', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'gpPageUrl', 'value' => '', 'title' => 'Google+ Page URL', 'description' => 'Google+ Page URL', 'group' => 'Social', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'url' => []])], ['key' => 'twitterSite', 'value' => '', 'title' => 'Twitter Card Site', 'description' => '@username for the website used', 'group' => 'Social', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'reCaptchaKey', 'value' => '', 'title' => 'reCaptcha Site Key', 'description' => 'reCaptcha Site Key', 'group' => 'API', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'reCaptchaSecret', 'value' => '', 'title' => 'reCaptcha Secret', 'description' => 'reCaptcha Secret', 'group' => 'API', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'facebookAppId', 'value' => '', 'title' => 'Facebook App ID', 'description' => 'Facebook App ID', 'group' => 'API', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'facebookAppSecret', 'value' => '', 'title' => 'Facebook App Secret', 'description' => 'Facebook App Secret', 'group' => 'API', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'googleClientId', 'value' => '', 'title' => 'Google Client ID', 'description' => 'Google Client ID', 'group' => 'API', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'googleClientSecret', 'value' => '', 'title' => 'Google Client Secret', 'description' => 'Google Client Secret', 'group' => 'API', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'flickrClientKey', 'value' => '', 'title' => 'Flickr Client Key', 'description' => 'Flickr Client Key', 'group' => 'API', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'flickrClientSecret', 'value' => '', 'title' => 'Flickr Client Secret', 'description' => 'Flickr Client Secret', 'group' => 'API', 'type' => 'passwordInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'androidThemeColor', 'value' => '#3c8dbc', 'title' => 'Android Theme Color', 'description' => 'Android theme color', 'group' => 'Theme', 'type' => 'textInput', 'data' => '[]', 'default' => '#3c8dbc', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'msTileColor', 'value' => '#3c8dbc', 'title' => 'MS Tile Color', 'description' => 'Background color for a live tile', 'group' => 'Theme', 'type' => 'textInput', 'data' => '[]', 'default' => '#3c8dbc', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'safariMaskColor', 'value' => '#3c8dbc', 'title' => 'Safari Mask Color', 'description' => 'Safari pinned tab color', 'group' => 'Theme', 'type' => 'textInput', 'data' => '[]', 'default' => '#3c8dbc', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'googleCustomSearch', 'value' => '', 'title' => 'Google Custom Search', 'description' => 'CX code: 123456789012345678901:abcdefjh123', 'group' => 'Enhancements', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'googleAnalytics', 'value' => '', 'title' => 'Google Analytics', 'description' => 'Tracking ID: UA-1111111-22', 'group' => 'Enhancements', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'disqus', 'value' => '', 'title' => 'Disqus', 'description' => 'Disqus shortname', 'group' => 'Enhancements', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'zopim', 'value' => '', 'title' => 'Zopim Chat', 'description' => 'Zopim ID: 5d8f1e3c8f77c45608ada76d51256aad', 'group' => 'Enhancements', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'addthis', 'value' => '', 'title' => 'Addthis', 'description' => 'Addthis ID: ra-123a1234567890b1', 'group' => 'Enhancements', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'headJs', 'value' => '', 'title' => 'Header JS', 'description' => 'Header Javascript', 'group' => 'Enhancements', 'type' => 'textarea', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'adsense', 'value' => '', 'title' => 'Google Adsense', 'description' => 'Client ID: ca-pub-1234567890123456', 'group' => 'Ads', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'amzTracking', 'value' => '', 'title' => 'Amazon Tracking ID', 'description' => 'Tracking ID: yourname-11', 'group' => 'Ads', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'amzAds', 'value' => '', 'title' => 'Amazon Native Ads', 'description' => 'Ad Instance ID: 12abc1ab-ab12-1234-a123-1abcd123456a', 'group' => 'Ads', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'amzSearchAds', 'value' => '', 'title' => 'Amazon Search Ads', 'description' => 'Link ID: 12abc1ab-ab12-1234-a123-1abcd123456a', 'group' => 'Ads', 'type' => 'textInput', 'data' => '[]', 'default' => '', 'rules' => json_encode(['safe' => [], 'string' => []])], ['key' => 'languageUrlCode', 'value' => '0', 'title' => 'Language URL', 'description' => 'Include language code in URL', 'group' => 'System', 'type' => 'dropDownList', 'data' => json_encode(Core::getYesNoOption()), 'default' => '0', 'rules' => json_encode(['required' => [], 'boolean' => []])], ['key' => 'debug', 'value' => '0', 'title' => 'Debug Mode', 'description' => 'Turn debug mode ON/OFF', 'group' => 'System', 'type' => 'dropDownList', 'data' => json_encode(Core::getYesNoOption()), 'default' => '0', 'rules' => json_encode(['required' => [], 'boolean' => []])]];
     /* delete old settings */
     $settings = Setting::find()->all();
     foreach ($settings as $setting) {
         if (!in_array($setting->key, array_column($s, 'key'))) {
             $setting->delete();
         }
     }
     /* sync */
     foreach ($s as $i => $setting) {
         $conf = Setting::findOne($setting['key']);
         if (!$conf) {
             $conf = new Setting();
             $conf->key = $setting['key'];
             $conf->value = $setting['value'];
         }
         $conf->title = $setting['title'];
         $conf->description = $setting['description'];
         $conf->group = $setting['group'];
         $conf->type = $setting['type'];
         $conf->data = $setting['data'];
         $conf->default = $setting['default'];
         $conf->rules = $setting['rules'];
         $conf->key_order = $i;
         $conf->save();
     }
 }
 /**
  * Grabs all new notifications and adds them to the sender's inform queue.
  *
  * This method gets called by dashboard's hooks file to display new
  * notifications on every pageload.
  *
  * @since 2.0.18
  * @access public
  *
  * @param Gdn_Controller $Sender The object calling this method.
  */
 public static function informNotifications($Sender)
 {
     $Session = Gdn::session();
     if (!$Session->isValid()) {
         return;
     }
     $ActivityModel = new ActivityModel();
     // Get five pending notifications.
     $Where = array('NotifyUserID' => Gdn::session()->UserID, 'Notified' => ActivityModel::SENT_PENDING);
     // If we're in the middle of a visit only get very recent notifications.
     $Where['DateUpdated >'] = Gdn_Format::toDateTime(strtotime('-5 minutes'));
     $Activities = $ActivityModel->getWhere($Where, 0, 5)->resultArray();
     $ActivityIDs = array_column($Activities, 'ActivityID');
     $ActivityModel->setNotified($ActivityIDs);
     $Sender->EventArguments['Activities'] =& $Activities;
     $Sender->fireEvent('InformNotifications');
     foreach ($Activities as $Activity) {
         if ($Activity['Photo']) {
             $UserPhoto = anchor(img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon');
         } else {
             $UserPhoto = '';
         }
         $Excerpt = Gdn_Format::plainText($Activity['Story']);
         $ActivityClass = ' Activity-' . $Activity['ActivityType'];
         $Sender->informMessage($UserPhoto . Wrap($Activity['Headline'], 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . $ActivityClass . ($UserPhoto == '' ? '' : ' HasIcon'));
     }
 }
 public function __construct(array $outputs, $confirms = 1)
 {
     $this->data = $outputs;
     $this->minimumConfirms = $confirms;
     $this->total = count($outputs);
     // do calculation only if at least 1 output
     if ($this->total > 0) {
         $amounts = array_column($outputs, 'amount');
         $this->amountsSum = array_sum($amounts);
         $amountPairs = [];
         foreach ($amounts as $amount) {
             $amount = (string) $amount;
             // cast float to string, because array_key_exists can handle only string or integer
             // if key exists, then add +1 to value that means that amount already was counted
             if (array_key_exists($amount, $amountPairs)) {
                 $amountPairs[$amount] = $amountPairs[$amount] + 1;
             } else {
                 // new result, just add initial 1
                 $amountPairs[$amount] = 1;
             }
         }
         $this->amountPairs = $amountPairs;
         ksort($this->amountPairs);
         // sort incrementing by amount
     }
 }
 public function defaultAction()
 {
     $pageSize = 20;
     // 获取参数
     $page = Pager::get();
     $title = Request::getGET('title');
     $status = (int) Request::getGET('status');
     // 构建where
     $where = array(array('user_id', '=', $this->loginUserInfo['id']), array('is_diy', '=', 1));
     if (!empty($status) && $status != -1) {
         $where[] = array('hidden', '=', $status - 1);
     }
     if (!empty($title)) {
         $where[] = array('title', 'LIKE', "%{$title}%");
     }
     // 获取数据
     $offset = ($page - 1) * $pageSize;
     $contestList = OjContestInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = 0;
     if (!empty($contestList)) {
         $allCount = OjContestInterface::getCount($where);
     }
     $userIds = array_unique(array_column($contestList, 'user_id'));
     $userHash = UserCommonInterface::getById(array('id' => $userIds));
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     // 输出
     $this->renderFramework(array('contestList' => $contestList, 'userHash' => $userHash, 'html' => $html), 'setup/contest/list.php');
 }
Esempio n. 5
0
function Moodle_GetUserId($usert)
{
    /**
     * Returns the moodle id of the username $usert
     * @author  Germán Sánchez (GREC-ESADE), Collage
     * @version 24.04.2014
     */
    global $debugar;
    $moodleUsers = Moodle_GetUsersList();
    $moodleUsers = objectToArray($moodleUsers);
    // $moodleUsers es un array con 'users, que es otro array:
    // [0][1]... con [id] y [username]
    //echo '<pre>'.print_r($moodleUsers['users'], TRUE).'</pre>';
    $key = array_search($usert, array_column($moodleUsers['users'], 'username'));
    if ($debugar) {
        echo '<h1>key = ' . $key . '</h1>';
    }
    if ($key != NULL) {
        $userid = $moodleUsers['users'][$key]['id'];
    } else {
        $userid = NULL;
    }
    if ($debugar) {
        echo '<h1>userid = ' . $userid . '</h1>';
    }
    if ($debugar) {
        echo '<pre>' . print_r($moodleUsers['users'], TRUE) . '</pre>';
    }
    return $userid;
}
Esempio n. 6
0
 /**
  * 登陆
  */
 public function login()
 {
     if (IS_POST) {
         //登陆验证
         if ($this->model->create() !== false) {
             if (($result = $this->model->login(I('post.'))) !== false) {
                 //是否记住密码
                 $remember = false;
                 if (I('post.remember')) {
                     $remember = true;
                 }
                 //保存用户登录
                 login($result['userinfo'], $remember);
                 //保存用户权限ids和urls
                 $permissions = $result['permissions'];
                 permissionId(array_column($permissions, 'id'));
                 permissionURL(array_column($permissions, 'url'));
                 //跳转后台首页
                 $this->success('登陆成功', U('Index/index'));
                 return;
             }
         }
         $this->error(show_model_error($this->model), U('login'));
     } else {
         //登陆表单
         $this->display('login');
     }
 }
Esempio n. 7
0
 public function findEventsByType($logTypeID)
 {
     return $this->cache->load('logEvents-' . $logTypeID, function (&$dependencies) use($logTypeID) {
         return array_column($this->em->createQuery('SELECT e.id, e.name FROM ' . EventLog::class . ' e INDEX BY e.id
              WHERE e.logType = :typeID')->setParameter('typeID', $logTypeID)->getArrayResult(), 'name', 'id');
     });
 }
 public function parse(\SplFileInfo $file, string $filename = null, string $title = null) : Dictionary
 {
     $dictionary = new Dictionary();
     if (!$file instanceof \SplFileObject) {
         $file = $file->openFile();
     } else {
         $file->rewind();
     }
     $file->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::READ_AHEAD | \SplFileObject::SKIP_EMPTY);
     foreach ($file as $line) {
         $this->parseLine($dictionary, $line);
     }
     $this->wholeText .= implode('', array_column(array_column($dictionary->getWords(), 'text'), 0));
     if ($this->wholeText === '') {
         throw new SyntaxException(_('制御文字や空白文字のみで構成された辞書は変換できません。'));
     }
     $regard = $this->generateRegard();
     if ($regard) {
         $metaFields['@regard'] = $this->generateRegard();
     }
     if (!is_null($title)) {
         $metaFields['@title'] = $title;
     } elseif (!is_null($filename)) {
         $titleFromFilename = $this->getTitleFromFilename($filename);
         if ($titleFromFilename) {
             $metaFields['@title'] = $titleFromFilename;
         }
     }
     if (isset($metaFields)) {
         $dictionary->setMetadata($metaFields);
     }
     return $dictionary;
 }
 public function get_user_tokens($user_id)
 {
     $ar = ['users_id' => $user_id];
     $this->db->select('token');
     $res = $this->db->get_where($this->table, $ar)->result_array();
     return array_column($res, 'token');
 }
Esempio n. 10
0
 public function draw()
 {
     $temp = "";
     $host = $this->parameters["app"]->server["HTTP_HOST"];
     $uri = $this->parameters["app"]->server["REQUEST_URI"];
     $actualLink = "http://{$host}{$uri}";
     $relative = $this->parameters["app"]->server["RELATIVE"];
     foreach ($this->tags["menu"] as $i) {
         $prePath = "";
         if ($i["relative"]) {
             $prePath = $relative;
         }
         $active = $this->isSubString($actualLink, array_merge(array_column($i["submenu"], 'link'), array($i["link"]))) ? "active" : "";
         if (is_array($i["submenu"]) && count($i["submenu"]) < 1) {
             $temp .= "<li class='{$active}'><a href='{$prePath}{$i['link']}'>{$i['label']}</a></li>";
         } else {
             $temp .= "<li class='dropdown {$active}'>";
             $temp .= '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' . $i["label"] . '<span class="caret"></span>' . '</a>' . '<ul class="dropdown-menu">';
             foreach ($i["submenu"] as $j) {
                 $prePath = "";
                 if ($j["relative"]) {
                     $prePath = $relative;
                 }
                 $temp .= "<li><a href='{$prePath}{$j['link']}'>{$j['label']}</a></li>";
             }
             $temp .= "</ul></li>";
         }
     }
     return $temp;
 }
 public function toString($startCountAt = 0)
 {
     foreach ($this->myArray[0] as $key => $value) {
         $this->array_columns[$key] = array_column($this->myArray, $key);
     }
     $output = '';
     $maxColWidths = $this->calculateMaxWidths($this->array_columns, $startCountAt);
     $output .= sprintf("%{$maxColWidths['row_num_col']}s%s", "", $this->rowNumbersColSep);
     $headerKeys = array_keys($this->array_columns);
     foreach ($headerKeys as $heading) {
         $headingFormat = "%-{$maxColWidths[$heading]}s{$this->cellSep}";
         $output .= sprintf($headingFormat, $heading);
     }
     $output .= "\n";
     foreach ($maxColWidths as $maxColWidth) {
         $output .= sprintf("%{$maxColWidth}s%s", str_repeat($this->headerSep, $maxColWidth), $this->cellSep);
     }
     $output .= "\n";
     for ($row = 0, $maxRows = count(array_values($this->array_columns)[0]); $row < $maxRows; $row++) {
         $output .= sprintf("%{$maxColWidths['row_num_col']}d%s", $startCountAt, $this->rowNumbersColSep);
         $keysCount = 0;
         foreach (array_values($this->array_columns) as $data) {
             $maxDataWidth = $maxColWidths[$headerKeys[$keysCount]];
             $output .= sprintf("%-{$maxDataWidth}s%s", $data[$row], $this->cellSep);
             $keysCount += 1;
         }
         $startCountAt += 1;
         $output .= "\n";
         foreach ($maxColWidths as $maxColWidth) {
             $output .= sprintf("%{$maxColWidth}s%s", str_repeat($this->headerSep, $maxColWidth), $this->cellSep);
         }
         $output .= "\n";
     }
     return $output;
 }
Esempio n. 12
0
 /**
  * set or get a  company config value
  * json_decode/encode automatically
  * @param string $key
  * @param mixed $value
  * @return
  *	get: the config value, false if not found
  *	set: the insert or update query
  */
 function config($key = null, $value = null)
 {
     $db = $this->load->database('', true);
     if (is_null($key)) {
         $result = $db->select('id, key, value')->from('company_config')->where('company', $this->id)->get()->result_array();
         return array_column($result, 'value', 'key');
     }
     $row = $db->select('id,value')->from('company_config')->where('company', $this->id)->where('key', $key)->get()->row();
     if (is_null($value)) {
         if ($row) {
             $json_value = json_decode($row->value);
             if (is_null($json_value)) {
                 return $row->value;
             } else {
                 return $json_value;
             }
         } else {
             return;
         }
     } else {
         if (is_array($value)) {
             $value = json_encode($value);
         }
         return $db->upsert('company_config', array('value' => $value, 'id' => $row->id));
     }
 }
Esempio n. 13
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     $this->setPropertiesDefine(array('parent_id' => array('alias' => '上级部门', 'options' => function () {
         $data = Department::find()->field('id', 'parent_id', 'name')->all(true);
         $tmp = array_combine(array_column($data, 'id'), array_column($data, 'name'));
         array_unshift_assoc($tmp, 0, '顶级');
         return $tmp;
     }, 'form' => function ($val = null, self $instance = null) {
         $data = Department::find()->field('id', 'parent_id', 'name')->all(true);
         return ViewBase::generateParentTreeSelector($data, $instance);
     }), 'manager_id' => array('alias' => '负责人', 'options' => function () {
         $data = User::find('state=?', User::STATE_ENABLED)->field('id', 'name')->all(true);
         return array_combine(array_column($data, 'id'), array_column($data, 'name'));
     }, 'display' => function (self $item) {
         $tmp = User::findOneByPk($item->manager_id);
         if (!$tmp) {
             return '';
         }
         return $tmp->state == User::STATE_ENABLED ? $tmp->name : '<del>' . $tmp->name . '</del>';
     }), 'stage_id' => array('options' => function () {
         return WorkStage::$work_stage_list;
     }), 'stage_name' => array('getter' => function ($item) {
         if ($item->stage_id) {
             return WorkStage::$work_stage_list[$item->stage_id];
         }
         return '';
     }, 'alias' => '负责流程')));
 }
Esempio n. 14
0
 public function __construct()
 {
     global $CFG_GLPI, $DB;
     // construct api url
     self::$api_url = trim($CFG_GLPI['url_base_api'], "/");
     // Don't display error in result
     set_error_handler(array('Toolbox', 'userErrorHandlerNormal'));
     ini_set('display_errors', 'Off');
     // Avoid keeping messages between api calls
     $_SESSION["MESSAGE_AFTER_REDIRECT"] = '';
     // check if api is enabled
     if (!$CFG_GLPI['enable_api']) {
         $this->returnError(__("API disabled"), "", "", false);
         exit;
     }
     // retrieve ip of client
     $this->iptxt = isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : $_SERVER["REMOTE_ADDR"];
     $this->ipnum = strstr($this->iptxt, ':') === false ? ip2long($this->iptxt) : '';
     // check ip access
     $apiclient = new APIClient();
     $where_ip = "";
     if ($this->ipnum) {
         $where_ip .= " AND (`ipv4_range_start` IS NULL\n                             OR (`ipv4_range_start` <= '{$this->ipnum}'\n                                 AND `ipv4_range_end` >= '{$this->ipnum}'))";
     } else {
         $where_ip .= " AND (`ipv6` IS NULL\n                             OR `ipv6` = '" . $DB->escape($this->iptxt) . "')";
     }
     $found_clients = $apiclient->find("`is_active` = '1' {$where_ip}");
     if (count($found_clients) <= 0) {
         $this->returnError(__("There isn't an active api client matching your ip adress in the configuration") . " (" . $this->iptxt . ")", "", "ERROR_NOT_ALLOWED_IP", false);
     }
     $app_tokens = array_column($found_clients, 'app_token');
     $apiclients_id = array_column($found_clients, 'id');
     $this->app_tokens = array_combine($apiclients_id, $app_tokens);
 }
Esempio n. 15
0
 /**
  * renders the edit form and calls the createProccess
  * method located in the main Controller class in order to update
  * the database data
  */
 public function edit()
 {
     $id = empty($this->urlParams['q1']) ? 1 : $this->urlParams['q1'];
     $cnl = $this->model->get($id);
     if (false === $cnl) {
         // not found
         $this->app->flashNow('errors', $this->classMessages['not_found']);
     }
     $allCats = $this->model->getCats();
     $cnlCats = $this->model->getAssosCats($id);
     /* check the checkboxes if the categories belong to our channel */
     foreach ($allCats as $key => $value) {
         if (false !== array_search($value['title'], array_column($cnlCats, 'title'))) {
             $allCats[$key]['checked'] = true;
         }
     }
     $post = $this->app->request->post();
     if (isset($post['submit'])) {
         $createProccess = $this->createProccess($post, $this->reqFields, 'update', $cnl);
         if (true === $createProccess['success']) {
             $this->app->flash('success', $createProccess['message']);
             $this->redirectInAdmin($this->type);
         } else {
             $this->app->flashNow('errors', $createProccess['message']);
         }
     }
     $this->app->render($this->getView(), array('cats' => $allCats, 'cnl' => $cnl));
 }
Esempio n. 16
0
function parseLog()
{
    // Получает данные из конфига
    $ini_array = parse_ini_file("./config.ini", true);
    $log1 = $ini_array['GPBTest_Log']['log1'];
    $log2 = $ini_array['GPBTest_Log']['log2'];
    // Инициализация массивов
    $url_array = $ip_log = $val = array();
    // Цикл по второму логу с IP, Browser & OS
    foreach (file($log2) as $line) {
        $ip_log[] = explode('|', $line);
    }
    // Цикл по первому логу со сбором выходного массива с подключением первого лога
    foreach (file($log1) as $line) {
        $val = explode('|', $line);
        // Получаем ключ во втором массиве, чтобы получить browser & os
        $key = array_search($val[2], array_column($ip_log, 0));
        // Если ключ найден - собираем полный массив, если нет - без browser & os
        if ($key === false) {
            $array[] = array('date' => $val[0], 'time' => $val[1], 'ip' => $val[2], 'url_referer' => $val[3], 'url_view' => $val[4], 'browser' => '', 'os_name' => '');
        } else {
            $array[] = array('date' => $val[0], 'time' => $val[1], 'ip' => $val[2], 'url_referer' => $val[3], 'url_view' => $val[4], 'browser' => $ip_log[$key][1], 'os_name' => $ip_log[$key][2]);
        }
    }
    return $array;
}
Esempio n. 17
0
 /**
  * 接口:根据分类获取该分类下的所有sku信息
  * @author yelongyi@yelongyi.com
  * @since 2015-08-25 11:20:48
  * #param int category_id 分类id
  * #param int deep 默认返回该分类下的SKU,如果为1,那么返回所有该分类所属的SKU
  * #param array fields 需要取的字段信息,不传仅返回sku_number
  * @return json 返回json格式信息
  */
 public function get_sku_by_category()
 {
     try {
         $category_id = $this->input->post('category_id');
         if (empty($category_id)) {
             throw new Exception("No incoming parameter 'category_id'");
         }
         $fields = $this->input->post('fields') ?: ['sku_number'];
         $category_list = $category_id;
         //如果deep参数为1,查询所有子孙分类的sku
         if ($this->input->get('deep') == 1) {
             $category_list = $this->MCategory->get_category_child($category_id, true);
             if (empty($category_list)) {
                 throw new Exception('No data can be returned');
             }
             $category_list = array_column($category_list, 'id');
         }
         $sku_arr = $this->MSku->get_sku_by_category($category_list, $fields);
         if (empty($sku_arr)) {
             throw new Exception('No data can be returned');
         }
         $returnArr = array();
         $i = 0;
         foreach ($sku_arr as $sku_info) {
             $returnArr['data'][$i] = $sku_info;
             $i++;
         }
         if (empty($returnArr)) {
             $returnArr['data'] = array();
         }
         $this->success($returnArr);
     } catch (Exception $e) {
         $this->failed($e->getMessage());
     }
 }
Esempio n. 18
0
 public function toString($headerSep = '.', $rowNumbersColSep = '+', $cellSep = '|', $startCountAt = 0)
 {
     $this->setHeaderSeparator($headerSep);
     $this->setRowNumbersColSeparator($rowNumbersColSep);
     $this->setCellSeparator($cellSep);
     foreach ($this->myArray as $myArrays) {
         foreach ($myArrays as $key => $value) {
             $this->array_columns[$key] = array_column($this->myArray, $key);
         }
     }
     $output = '';
     foreach ($this->array_columns as $column_key => $column_value) {
         $first = true;
         foreach ($column_value as $index => $val) {
             $index += $startCountAt;
             if ($first) {
                 $header = "\n%8s\n{$this->rowNumbersColSep}{$this->headerSep}\n";
                 $output .= sprintf($header, $column_key);
                 $first = false;
             }
             $tableRows = "{$this->cellSep}%3d{$this->cellSep}%-7.7s{$this->cellSep}\n";
             $output .= sprintf($tableRows, $index, $val);
         }
     }
     return $output;
 }
Esempio n. 19
0
 public function lists($map = array(), $field = '', $order = '', $page = 0, $page_size = 0)
 {
     $pk = $this->pk;
     //主键
     $field = empty($field) ? $this->selectFields : $fields;
     $order = empty($order) ? $pk . ' desc' : $order;
     if ($page === 0) {
         $list = $this->where($map)->field($field)->order($order)->select();
     } else {
         $page_index = ($page - 1) * $page_size;
         $list = $this->where($map)->field($field)->order($order)->limit($page_index . ',' . $page_size)->select();
     }
     if (empty($list)) {
         return $list;
     }
     //查询会员表
     $member_id = array_column($list, 'member_id');
     $member_id = array_unique($member_id);
     $member_map['id'] = array('in', $member_id);
     $member_list = D('Member')->_list($member_map, 'id,username');
     $member_list = ArrayHelper::array_key_replace($member_list, 'id', 'member_id');
     $member_list = array_column($member_list, null, 'member_id');
     foreach ($list as $_k => $_v) {
         $list[$_k] = array_merge($_v, $member_list[$_v['member_id']]);
     }
     return $list;
 }
 public function filtroAction($id)
 {
     if ($this->request->isPost()) {
         $categoria = Categorias::findById($id);
         if (!empty($categoria->subcategorias)) {
             $array = Categorias::getChildrensIds($categoria);
             $array[] = $categoria->_id;
             $this->view->indice = $array;
         } else {
             $this->view->indice = $id;
         }
         $this->view->id = $id;
         if ($this->request->getPost('filtros')) {
             $itens = array_values(array_unique(array_column($this->request->getPost('filtros'), 'tipo')));
             $filtros = array();
             foreach ($itens as $value) {
                 foreach ($this->request->getPost('filtros') as $key => $filtro) {
                     if ($value == $filtro['tipo']) {
                         $filtros[$value][] = $filtro['valor'];
                     }
                 }
             }
             $this->view->filtros = $filtros;
         } else {
             $this->view->filtros = array();
         }
         $this->view->pagina = 0;
         $this->session->set('filtros', $this->view->filtros);
         $this->view->disableLevel(View::LEVEL_AFTER_TEMPLATE);
     }
 }
 protected function _getPortableTableIndexesList($rows, $name = null)
 {
     foreach ($rows as $i => $row) {
         if (isset($row['indexDefinition']['field'])) {
             $columns = array($row['indexDefinition']['field']);
         } else {
             $columns = array_column($row['indexDefinition']['indexDefinitions'], 'field');
         }
         $rows[$i] = array('name' => $row['name'], 'columns' => $columns, 'primary' => false, 'unique' => $row['type'] === 'UNIQUE', 'flags' => !($row['type'] === 'UNIQUE') ? array($row['type']) : array());
     }
     $eventManager = $this->_platform->getEventManager();
     $indexes = array();
     foreach ($rows as $indexKey => $data) {
         $index = null;
         $defaultPrevented = false;
         if (null !== $eventManager && $eventManager->hasListeners(Events::onSchemaIndexDefinition)) {
             $eventArgs = new SchemaIndexDefinitionEventArgs($data, $name, $this->_conn);
             $eventManager->dispatchEvent(Events::onSchemaIndexDefinition, $eventArgs);
             $defaultPrevented = $eventArgs->isDefaultPrevented();
             $index = $eventArgs->getIndex();
         }
         if (!$defaultPrevented) {
             $index = new Index($data['name'], $data['columns'], $data['unique'], $data['primary'], $data['flags']);
         }
         if ($index) {
             $indexes[$indexKey] = $index;
         }
     }
     return $indexes;
 }
 /**
  * Gets statistics of table INSERTs by days as [dt => amount]
  * @param \DateTime $dateFrom
  * @param string $threshold
  * @param string $column
  * @param string $operator COUNT or SUM
  * @param string $condition optional WHERE condition
  * @param integer $cache cache duration
  * @return array
  */
 public static function getStatistics($dateFrom, $threshold = 'month', $column = 'id', $operator = 'COUNT', $condition = '', $cache = null)
 {
     $cache = $cache ?: \Yii::$app->params['cacheDuration'];
     $timestampBehavior = (new static())->getBehavior('timestamp');
     /** @var TimestampBehavior $timestampBehavior */
     $createdAtAttribute = $timestampBehavior->createdAtAttribute;
     return \Yii::$app->db->cache(function ($db) use($dateFrom, $threshold, $column, $operator, $condition, $createdAtAttribute) {
         /** @var \yii\db\Connection $db */
         $dateTo = new \DateTime();
         $dateInterval = new \DateInterval($threshold === 'year' ? 'P1M' : 'P1D');
         $dateRange = new \DatePeriod($dateFrom, $dateInterval, $dateTo);
         $range = [];
         foreach ($dateRange as $date) {
             /* @var \DateTime $date */
             $range[$date->format($threshold === 'year' ? 'Y-n' : 'Y-m-d')] = 0;
         }
         $date = $dateFrom->format('Y-m-d 00:00:00');
         $table = static::tableName();
         if (!empty($condition)) {
             $condition = "AND {$condition}";
         }
         $statistics = array_column($db->createCommand($threshold === 'year' ? "\n                SELECT CONCAT(YEAR({$createdAtAttribute}), '-', MONTH({$createdAtAttribute})) AS dt,\n                {$operator}({$column}) AS amount\n                FROM {$table}\n                WHERE {$createdAtAttribute} > '{$date}' {$condition}\n                GROUP BY dt\n            " : "\n                SELECT DATE({$createdAtAttribute}) AS dt, {$operator}({$column}) AS amount\n                FROM {$table}\n                WHERE {$createdAtAttribute} > '{$date}' {$condition}\n                GROUP BY dt\n            ")->queryAll(), 'amount', 'dt');
         return array_merge($range, $statistics);
     }, $cache);
 }
Esempio n. 23
0
 public function getList($ids)
 {
     $shops = $this->getShops($ids);
     //check if parent shops has to be loaded
     $mainIds = array_values(array_unique(array_filter(array_column($shops, '__shop_main_id'))));
     $mainIds = array_diff($mainIds, $ids);
     $parents = [];
     if (!empty($mainIds)) {
         $parents = $this->getShops($mainIds);
     }
     $result = [];
     foreach ($shops as $row) {
         $id = $row['__shop_id'];
         $mainId = $row['__shop_main_id'];
         if ($mainId && isset($parents[$mainId])) {
             $row['parent'] = $parents[$mainId];
         } elseif ($mainId && isset($shops[$mainId])) {
             $row['parent'] = $shops[$mainId];
         } else {
             $row['parent'] = null;
         }
         $result[$id] = $this->hydrator->hydrate($row);
     }
     return $result;
 }
 /**
  * @param string $fieldName
  * @param string[] $filenames
  * @param string $input
  * @param string $output
  * @dataProvider filenameProvider
  */
 public function testCorrect(string $fieldName, array $filenames, string $input, string $output)
 {
     $validator = new FileLocationValidator($fieldName, $filenames);
     $validator->setLogger($this);
     $this->{$output[0] === '/' ? 'assertRegExp' : 'assertSame'}($output, $validator->correct($input));
     $this->assertEquals($input !== $output && (empty($filenames[$input]) || $filenames[$input] !== $output) ? [\Psr\Log\LogLevel::ERROR] : [], array_column($this->logs, 'level'));
 }
Esempio n. 25
0
 private function _format_stock_list($stock_list = array())
 {
     //填充仓库名
     $warehouse_list = $this->_get_warehouses();
     $warehouse_ids = array_column($warehouse_list, 'warehouse_id');
     $warehouse_names = array_column($warehouse_list, 'warehouse_name');
     $warehouse_map = array_combine($warehouse_ids, $warehouse_names);
     $sku_numbers = array_column($stock_list, 'sku_number');
     $skus = $this->MSku->get_lists('*', array('in' => array('sku_number' => $sku_numbers)));
     $sku_numbers = array_column($skus, 'sku_number');
     $sku_map = array_combine($sku_numbers, $skus);
     //print_r($warehouse_map);
     foreach ($stock_list as &$item) {
         $warehouse_id = $item['warehouse_id'];
         $item['warehouse_name'] = isset($warehouse_map[$warehouse_id]) ? $warehouse_map[$warehouse_id] : '';
         //可售库存
         $item['sellable'] = $item['in_stock'] - $item['stock_locked'];
         $sku_number = $item['sku_number'];
         $item['sku_name'] = $sku_map[$sku_number]['name'];
         //print_r($warehouse_map[$warehouse_id]);
         //
         //限购值需要去redis取
     }
     unset($item);
     return $stock_list;
 }
 public function Chart()
 {
     $yesterday = Carbon::now();
     $start = $yesterday->copy()->addDays(-7);
     $end = $yesterday->copy();
     // for query
     $startBetween = $start->format('Y-m-d');
     $endBetween = $end->format('Y-m-d');
     $dates = [];
     while ($start->lte($end)) {
         $dates[] = $start->copy();
         $start->addDay();
     }
     $dates = collect($dates)->forPage(1, 7);
     $reports = \App\Order::ReportGroup("(orders.`tanggal` BETWEEN '{$startBetween}' AND '{$endBetween}')", "GROUP BY tanggal");
     $reports = ConvertRawQueryToArray($reports);
     $dataLastWeek = [];
     $dataLabelLastWeek = [];
     foreach ($dates as $date) {
         $idx = array_search($date->format("Y-m-d"), array_column($reports, "tanggal"));
         $val = 0;
         if (false !== $idx) {
             $d = $reports[$idx];
             $val = $d['jumlah'];
         }
         $dataLabelLastWeek[] = $date->format('d M Y');
         $dataLastWeek[] = $val;
     }
     return ['label' => $dataLabelLastWeek, 'data' => $dataLastWeek];
 }
function treeView($array, $id = 0, $allCategories, $productData)
{
    foreach ($array as $keyArray => $valueArray) {
        if ($array[$keyArray]->parent_category_id == $id) {
            $flag = array_search($array[$keyArray]->category_id, array_column(json_decode(json_encode($allCategories), true), 'parent_category_id'));
            if ($flag) {
                ?>
<optgroup
        label="<?php 
                echo $array[$keyArray]->display_name . $array[$keyArray]->category_name;
                ?>
">
    <?php 
                treeView($array, $array[$keyArray]->category_id, $allCategories, $productData);
                ?>
</optgroup>
<?php 
            } else {
                ?>
<option value="{{$array[$keyArray]->category_id }}" @if($array[$keyArray]->category_id == $productData['category_id']){{"selected"}}@endif>
    <?php 
                echo $array[$keyArray]->display_name . $array[$keyArray]->category_name;
                ?>
</option>
<?php 
            }
        }
    }
}
Esempio n. 28
0
 /**
  * @return string
  */
 public function run()
 {
     parent::run();
     if (null === $this->rootCategory) {
         return '';
     }
     $cacheKey = $this->className() . ':' . implode('_', [$this->viewFile, $this->rootCategory, null === $this->depth ? 'null' : intval($this->depth), intval($this->includeRoot), intval($this->fetchModels), intval($this->onlyNonEmpty), implode(',', $this->excludedCategories), \Yii::$app->request->url]) . ':' . json_encode($this->additional);
     if (false !== ($cache = \Yii::$app->cache->get($cacheKey))) {
         return $cache;
     }
     /** @var array|Category[] $tree */
     $tree = Category::getMenuItems(intval($this->rootCategory), $this->depth, boolval($this->fetchModels));
     if (true === $this->includeRoot) {
         if (null !== ($_root = Category::findById(intval($this->rootCategory)))) {
             $tree = [['label' => $_root->name, 'url' => Url::toRoute(['@category', 'category_group_id' => $_root->category_group_id, 'last_category_id' => $_root->id]), 'id' => $_root->id, 'model' => $this->fetchModels ? $_root : null, 'items' => $tree]];
         }
     }
     if (true === $this->onlyNonEmpty) {
         $_sq1 = (new Query())->select('main_category_id')->distinct()->from(Product::tableName());
         $_sq2 = (new Query())->select('category_id')->distinct()->from('{{%product_category}}');
         $_query = (new Query())->select('id')->from(Category::tableName())->andWhere(['not in', 'id', $_sq1])->andWhere(['not in', 'id', $_sq2])->all();
         $this->excludedCategories = array_merge($this->excludedCategories, array_column($_query, 'id'));
     }
     $tree = $this->filterTree($tree);
     $cache = $this->render($this->viewFile, ['tree' => $tree, 'fetchModels' => $this->fetchModels, 'additional' => $this->additional, 'activeClass' => $this->activeClass, 'activateParents' => $this->activateParents]);
     \Yii::$app->cache->set($cacheKey, $cache, 0, new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(Category::className()), ActiveRecordHelper::getCommonTag(Product::className())]]));
     return $cache;
 }
Esempio n. 29
0
 /**
  * @return string
  */
 public function buildSiteMap()
 {
     // we get all site pages
     $site_pages = $this->getSitePages();
     // we only take the last mod column from the site pages
     $dates = array_column($site_pages, 'last_mod');
     // we sort it
     sort($dates);
     // we get the website last modification date
     $lastmod = last($dates);
     // we get the base url from the website
     $url = route('home');
     $xml = [];
     $xml[] = '<?xml version="1.0" encoding="UTF-8"?' . '>';
     $xml[] = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     $xml[] = '  <url>';
     $xml[] = "    <loc>{$url}</loc>";
     $xml[] = "    <lastmod>{$lastmod}</lastmod>";
     $xml[] = '    <changefreq>daily</changefreq>';
     $xml[] = '    <priority>0.8</priority>';
     $xml[] = '  </url>';
     foreach ($site_pages as $page) {
         $xml[] = "  <url>";
         $xml[] = "    <loc>{$page['url']}</loc>";
         $xml[] = "    <lastmod>{$page['last_mod']}</lastmod>";
         $xml[] = "  </url>";
     }
     $xml[] = '</urlset>';
     return join("\n", $xml);
 }
Esempio n. 30
0
function billing_log_get_user_transactions($userId)
{
    lets_use('billing_account', 'billing_transaction', 'billing_description');
    $userMain = billing_account_get_account($userId, BILLING_ACCOUNT_TYPE_USER_MAIN, false);
    $acc[] = $userMain;
    $acc[] = billing_account_get_account($userId, BILLING_ACCOUNT_TYPE_USER_LOCKED, false);
    $acc = array_filter($acc);
    if (!$acc) {
        return [];
    }
    $tr = billing_transaction_get_accounts_transactions($acc);
    $types = billing_description_transaction_types();
    $accIds = array_unique(array_merge(array_column($tr, BILLING_TRANSACTION_FIELD_ACC_FROM), array_column($tr, BILLING_TRANSACTION_FIELD_ACC_TO)));
    $accData = billing_account_get_accounts($accIds);
    $ownersNames = billing_description_account_owner_names($accData);
    foreach ($tr as &$transaction) {
        $transaction['str_type'] = isset($types[$transaction[BILLING_TRANSACTION_FIELD_TYPE]]) ? $types[$transaction[BILLING_TRANSACTION_FIELD_TYPE]] : $types[0];
        $transaction['target_action'] = $transaction[BILLING_TRANSACTION_FIELD_ACC_FROM] == $userId ? 'в счет' : 'из';
        $transaction['prefix'] = $transaction[BILLING_TRANSACTION_FIELD_TYPE] == BILLING_TRANSACTION_TYPE_REFILL ? 'источника' : '';
        if ($transaction[BILLING_TRANSACTION_FIELD_ACC_FROM] == $userMain) {
            $transaction['target_owner'] = $ownersNames[$transaction[BILLING_TRANSACTION_FIELD_ACC_TO]];
        } else {
            $transaction['target_owner'] = $ownersNames[$transaction[BILLING_TRANSACTION_FIELD_ACC_FROM]];
        }
        $transaction['success'] = $transaction['status'] == BILLING_TRANSACTION_STATUS_SUCCESS;
    }
    return $tr;
}