当前位置: 首页>>代码示例>>PHP>>正文


PHP Accounts::getUsersByRole方法代码示例

本文整理汇总了PHP中Accounts::getUsersByRole方法的典型用法代码示例。如果您正苦于以下问题:PHP Accounts::getUsersByRole方法的具体用法?PHP Accounts::getUsersByRole怎么用?PHP Accounts::getUsersByRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Accounts的用法示例。


在下文中一共展示了Accounts::getUsersByRole方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sellersAction

 public function sellersAction()
 {
     $request = $this->request;
     $persistent = $this->persistent;
     // Reset
     $reset = $this->request->getQuery('reset', 'int');
     if (isset($reset)) {
         $persistent->sellerParams = null;
     }
     // Persistent parameters
     if (!is_array($persistent->sellerParams)) {
         $persistent->sellerParams = ['qry' => ['conditions' => "(active=1 OR active IS NULL)", 'order' => 'updated DESC'], 'sort' => ['page' => 1, 'perpage' => 20]];
     }
     $parameters = $persistent->sellerParams;
     $parameters['sort']['perpage'] = 20;
     $parameters['sort']['page'] = 1;
     if ($request->getQuery('page', 'int')) {
         $parameters['sort']['page'] = $request->getQuery('page', 'int');
     }
     if ($request->getQuery('perpage', 'int')) {
         $parameters['sort']['perpage'] = $request->getQuery('perpage', 'int');
     }
     // ----------------------------------------
     // Search
     if ($request->isPost()) {
         $parameters['search_virtcat'] = null;
         $parameters['search_mplace'] = null;
         $parameters['search_placer'] = null;
         $parameters['search_title'] = null;
         // Virtual category
         if (!empty($_POST['search_virtcat'])) {
             $search_virtcat_get = $request->getPost('search_virtcat', 'int');
             $parameters['search_virtcat'] = $search_virtcat_get;
             $search_virtcat = " AND tmaterial_id = {$search_virtcat_get}";
         } else {
             $search_virtcat = null;
         }
         // Marketplace
         if (!empty($_POST['search_mplace'])) {
             $search_mplace_get = $request->getPost('search_mplace', 'int');
             $parameters['search_mplace'] = $search_mplace_get;
             $search_mplace = " AND marketplace_id = {$search_mplace_get}";
         } else {
             $search_mplace = null;
         }
         // Placer
         if (!empty($_POST['search_placer'])) {
             $search_placer_get = $request->getPost('search_placer', 'int');
             $parameters['search_placer'] = $search_placer_get;
             $search_placer = " AND user_id = {$search_placer_get}";
         } else {
             $search_placer = null;
         }
         // Title
         if (!empty($_POST['search_title'])) {
             $search_title_get = $request->getPost('search_title', 'string');
             $parameters['search_title'] = $search_title_get;
             $search_title = " AND fio LIKE '%{$search_title_get}%'";
         } else {
             $search_title_get = null;
             $search_title = null;
         }
         // Search parameters
         $parameters['qry'] = ['conditions' => "(active=1 OR active IS NULL)\n                    {$search_virtcat}\n                    {$search_mplace}\n                    {$search_placer}\n                    {$search_title}"];
     }
     // Other parameters
     $parameters['query_count'] = Marketseller::count($parameters['qry']);
     $parameters['qry']['order'] = "updated DESC";
     $parameters['qry']['limit'] = 10000;
     $persistent->sellerParams = $parameters;
     //        var_dump($parameters);
     // Find all placements that correspond to set parameters
     $sellers = Marketseller::find($parameters['qry']);
     // Paginator
     $paginator = new Paginator(["data" => $sellers, "limit" => $parameters['sort']['perpage'], "page" => $parameters['sort']['page']]);
     $this->view->page = $paginator->getPaginate();
     // Set selected search values
     $this->view->selected_virtcat = isset($parameters['search_virtcat']) && !empty($parameters['search_virtcat']) ? $parameters['search_virtcat'] : null;
     $this->view->selected_mplace = isset($parameters['search_mplace']) && !empty($parameters['search_mplace']) ? $parameters['search_mplace'] : null;
     $this->view->selected_placer = isset($parameters['search_placer']) && !empty($parameters['search_placer']) ? $parameters['search_placer'] : null;
     // Sellers count (overall or filtered)
     $this->view->sellers_count = $parameters['query_count'];
     // All marketplaces
     $marketplaces = Marketplace::find(["active = 1", 'order' => 'title ASC']);
     foreach ($marketplaces as $marketplace) {
         $marketplaces_array[$marketplace->id] = $marketplace->title;
     }
     $this->view->mplaces_list = $marketplaces_array;
     //        $this->view->marketplaces = $marketplaces;
     // All virtual categories
     $virtcats = PCategoryGroup::find(['order' => 'title ASC']);
     foreach ($virtcats as $virtcat) {
         $virtcats_array[$virtcat->id] = $virtcat->title;
     }
     $this->view->virtcats_list = $virtcats_array;
     // List of all active sellers (users) excluding APIs
     $all_sellers = Accounts::getUsersByRole('seller', false, 'name');
     $this->view->list_of_sellers = preg_grep('/^(?!API)/', $all_sellers);
 }
开发者ID:serge2300,项目名称:madeheart,代码行数:99,代码来源:SellerController.php

示例2: indexAction


//.........这里部分代码省略.........
 {
     $request = $this->request;
     $persistent = $this->persistent;
     // Reset
     $reset = $this->request->getQuery('reset', 'int');
     if (isset($reset)) {
         $persistent->makersParams = null;
     }
     // Persistent parameters
     if (!is_array($persistent->makersParams)) {
         $persistent->makersParams = ['qry' => ['conditions' => "id IS NOT NULL", 'order' => 'updated DESC'], 'sort' => ['page' => 1, 'perpage' => 50]];
     }
     $parameters = $persistent->makersParams;
     $parameters['sort']['perpage'] = isset($parameters['sort']['perpage']) ? $parameters['sort']['perpage'] : 50;
     $parameters['sort']['page'] = isset($parameters['sort']['page']) ? $parameters['sort']['page'] : 1;
     if ($request->getQuery('page', 'int')) {
         $parameters['sort']['page'] = $request->getQuery('page', 'int');
     }
     if ($request->getQuery('perpage', 'int')) {
         $parameters['sort']['perpage'] = $request->getQuery('perpage', 'int');
     }
     // Search
     if ($request->isPost()) {
         $parameters['search_region'] = null;
         $parameters['search_approved'] = null;
         // Placer
         if (!empty($_POST['search_region'])) {
             $search_region_get = $request->getPost('search_region', 'int');
             $parameters['search_region'] = $search_region_get;
             $search_region = " AND geo_id = {$search_region_get}";
         } else {
             $search_region = null;
         }
         // Name or ID
         if (!empty($_POST['search_name'])) {
             $search_name_get = $request->getPost('search_name', 'string');
             if (preg_match('/^[0-9,\\s]+$/', $request->getPost('search_name', 'string'))) {
                 $search_split = preg_split('/[,\\s]/', $search_name_get, 0, PREG_SPLIT_NO_EMPTY);
                 $search_name = implode(', ', $search_split);
                 $search_name = " AND id IN ({$search_name})";
             } else {
                 $search_name = " AND name LIKE '%{$search_name_get}%'";
             }
         } else {
             $search_name_get = null;
             $search_name = null;
         }
         // Email
         if (!empty($_POST['search_email'])) {
             $search_email_get = $request->getPost('search_email', 'string');
             $search_email = " AND email LIKE '%{$search_email_get}%'";
         } else {
             $search_email_get = null;
             $search_email = null;
         }
         // Phone
         if (!empty($_POST['search_phone'])) {
             $search_phone_get = $request->getPost('search_phone', 'string');
             $search_phone = " AND phone LIKE '%{$search_phone_get}%' OR phone2 LIKE '%{$search_phone_get}%'";
         } else {
             $search_phone_get = null;
             $search_phone = null;
         }
         // Approved status
         if (!empty($_POST['search_approved'])) {
             $search_approved_get = $request->getPost('search_approved', 'int');
             $parameters['search_approved'] = $search_approved_get;
             $search_approved = " AND approved = {$search_approved_get}";
         } else {
             $search_approved = null;
         }
         // Search parameters
         $parameters['qry'] = ['conditions' => "id IS NOT NULL\n                    {$search_region}\n                    {$search_name}\n                    {$search_email}\n                    {$search_phone}\n                    {$search_approved}"];
     }
     // Other parameters
     $parameters['count'] = PMaker::count($parameters['qry']);
     $parameters['qry']['order'] = "updated DESC";
     $parameters['qry']['limit'] = 10000;
     $persistent->makersParams = $parameters;
     //        var_dump($parameters);
     $makers = PMaker::find($parameters['qry']);
     // Paginator
     $paginator = new Paginator(["data" => $makers, "limit" => $parameters['sort']['perpage'], "page" => $parameters['sort']['page']]);
     $this->view->page = $paginator->getPaginate();
     // Set selected search values
     $this->view->selected_region = isset($parameters['search_region']) && !empty($parameters['search_region']) ? $parameters['search_region'] : null;
     $this->view->selected_approved = isset($parameters['search_approved']) && !empty($parameters['search_approved']) ? $parameters['search_approved'] : null;
     $this->view->makers_count = $parameters['count'];
     // All regions
     $this->view->regions_list = array_column(Geo::find(['order' => 'title ASC'])->toArray(), 'title', 'id');
     // Currencies
     $currencies_array = array_column(PCrosscurrency::find()->toArray(), 'title', 'title');
     $this->view->currencies_list = ['UAH' => $currencies_array['UAH']] + $currencies_array;
     // Countries
     $countries_array = array_column(Countries::find("active=1")->toArray(), 'title', 'id');
     $ukraine = array_search('Украина', $countries_array);
     $this->view->countries_list = [$ukraine => $countries_array[$ukraine]] + $countries_array;
     $this->view->users_list = Accounts::getUsersByRole(['researcher', 'mobilegroup'], false, 'name ASC');
     $this->view->can_edit = AccRoles::findFirst("user_id={$this->auth->id} AND (role_id=991 OR role_id=5)");
 }
开发者ID:serge2300,项目名称:madeheart,代码行数:101,代码来源:MakerslistController.php

示例3: stats

 /**
  * Common function for gathering stats
  *
  * @param string $input_role - user role
  * @param string $selspec - identificator for various types of seller stats (marketplaces, lang)
  */
 private function stats($input_role = null, $selspec = null)
 {
     // If there is no role specified this is a regular type of stats (phorocoder, translators, moderators...)
     $user_roles = $input_role == null ? $this->user_roles : $input_role;
     $months = $this->months;
     $days_ru = $this->days_ru;
     $month_and_year = date('m.Y', time());
     // Current month and year
     // Change month and year to ones selected by user
     if ($this->request->isPost() && !empty($this->request->getPost('month_and_year', 'string'))) {
         $month_and_year = $this->request->getPost('month_and_year', 'string');
     }
     $first_day_of_month = strtotime("01.{$month_and_year}");
     $first_day_of_next_month = strtotime("01.{$month_and_year} + 1 month");
     $num_of_days = (int) (($first_day_of_next_month - $first_day_of_month) / 86400);
     // Number of days in the month
     // Array of days in the selected month in unix timestamp
     for ($i = 1; $i <= $num_of_days; $i++) {
         $days[] = strtotime("{$i}.{$month_and_year}");
     }
     $days[] = $first_day_of_next_month;
     // Find stats for a month
     // photocoder, copywriter/moder, translator/moder
     if ($input_role == null) {
         $tasks = new PTasks();
         // @todo remove + 7200 !!!!!!!!!!!!!!!! set db server to correct time
         $sql = "SELECT COUNT(t1.id) AS count, FROM_UNIXTIME(t1.tstart + 7200, '%Y-%m-%d') AS cdate, t1.tstart, t1.trole, t1.tlang, t1.tassignee, t1.tprodid\n                    FROM p_tasks AS t1\n                    WHERE t1.tstart BETWEEN {$first_day_of_month} AND {$first_day_of_next_month} AND (t1.tstatus = 3 OR t1.tstatus = 5)\n                    GROUP BY t1.trole, t1.tlang, t1.tassignee, t1.tprodid, cdate\n                    ORDER BY t1.tassignee DESC;";
         $stats = new Resultset(null, $tasks, $tasks->getReadConnection()->query($sql));
         $stats = $stats->toArray();
         // seller
     } elseif ($input_role == 'seller') {
         $field = "user_id";
         if ($selspec == 'mplace') {
             $field = "marketplace_id";
         }
         // Marketplaces stats
         if ($selspec == 'lang') {
             $field = "langcode";
         }
         // Langs stats
         $tasks = new MPlacement();
         $sql = "SELECT COUNT(mp.id) AS count, FROM_UNIXTIME(mp.created + 7200, '%Y-%m-%d') AS cdate, mp.created, mp.user_id, mp.marketplace_id, mp.langcode\n                    FROM mplacement AS mp\n                    WHERE mp.created BETWEEN {$first_day_of_month} AND {$first_day_of_next_month}\n                    GROUP BY mp.{$field}, cdate\n                    ORDER BY mp.{$field}, cdate";
         $stats = new Resultset(null, $tasks, $tasks->getReadConnection()->query($sql));
         $stats = $stats->toArray();
     }
     // Find regular sellers and APIs
     if ($input_role == 'seller' && $selspec == null) {
         $all_sellers = Accounts::getUsersByRole('seller', false, 'name');
         $this->view->regular_sellers = $regular_sellers = preg_grep('/^(?!API)/', $all_sellers);
         $this->view->api_sellers = $api_sellers = preg_grep('/^API/', $all_sellers);
     }
     // All marketplaces
     if ($input_role == 'seller' && $selspec == 'mplace') {
         $all_marketplaces = array_column(Marketplace::find(['columns' => 'title, id', 'order' => 'title'])->toArray(), 'title', 'id');
     }
     // All langs
     if ($input_role == 'seller' && $selspec == 'lang') {
         $all_langs = array_column(PLangs::find(['columns' => 'alias', 'order' => 'id'])->toArray(), 'alias', 'alias');
     }
     $roles = [];
     $assignee = [];
     foreach ($stats as $stat) {
         // Regular stats
         if ($input_role == null) {
             $roles[$stat['trole']][$stat['tlang']][$stat['tassignee']][] = $stat['tstart'];
             // Seller stats
         } elseif ($input_role == 'seller' && $selspec == null) {
             $seller_stats[$stat['user_id']][$stat['cdate']] = (int) $stat['count'];
             // Seller marketplaces stats
         } elseif ($input_role == 'seller' && $selspec == 'mplace') {
             $seller_stats[$stat['marketplace_id']][$stat['cdate']] = (int) $stat['count'];
             // Seller langs stats
         } elseif ($input_role == 'seller' && $selspec == 'lang') {
             $seller_stats[$stat['langcode']][$stat['cdate']] = (int) $stat['count'];
         }
         // Link user_id to his name if it's not already linked
         // Regular stats
         if ($input_role == null) {
             if (empty($assignee[$stat['tassignee']])) {
                 if ($acc_name = Accounts::findFirst($stat['tassignee'])) {
                     $assignee[$stat['tassignee']] = $acc_name->name;
                 }
             }
             // Seller stats
         } elseif ($input_role == 'seller' && $selspec == null) {
             if (empty($assignee[$stat['user_id']])) {
                 foreach ($all_sellers as $seller_id => $seller_name) {
                     if ($stat['user_id'] == $seller_id) {
                         $assignee[$stat['user_id']] = $seller_name;
                     }
                 }
             }
             // Seller marketplaces stats
         } elseif ($input_role == 'seller' && $selspec == 'mplace') {
//.........这里部分代码省略.........
开发者ID:serge2300,项目名称:madeheart,代码行数:101,代码来源:StatController.php


注:本文中的Accounts::getUsersByRole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。