예제 #1
0
                ?>
" class="public_red_normal">разблокировать деньги</a>
			<?php 
            }
            ?>
			
			<br><br>
			<?php 
            if (hasPermissions('users')) {
                ?>
 Права: 
			<a href=".?action=chmoder&id=<?php 
                echo $user['uid'];
                ?>
" class="blue"><?php 
                echo is_moder($user['role']) ? 'снять' : 'дать';
                ?>
 модератора</a> |
			<a href=".?action=chredact&id=<?php 
                echo $user['uid'];
                ?>
" class="blue"><?php 
                echo is_redactor($user['role']) ? 'снять' : 'дать';
                ?>
 редактора</a>
            <?php 
                if ($user['active'] == 'f') {
                    ?>
 | <a href="/siteadmin/users/?action=activate&amp;login=<?php 
                    echo $user['login'];
                    ?>
예제 #2
0
 /**
  * @deprecated см GetCounts
  * 
  * Получает массив с количествм сообщений, разбитых по типам
  *
  * @param integer $user_id          id пользователя, для которого считаем
  * @param array $fromType           типы отзывов ('norisk' - СБР-отзывы, 'emp' - от работодателей, 'frl' - от фрилансеров, 'my' - мои)
  *
  * @return array                    массив данных
  */
 function GetCounts_OLD($user_id, $fromType)
 {
     global $DB;
     $bPermissions = hasPermissions('users');
     $ret = array('all' => array('p' => 0, 'n' => 0, 'm' => 0));
     $ret['norisk'] = $ret['total'] = $ret['emp'] = $ret['frl'] = $ret['my'] = $ret['tu_orders'] = $ret['all'];
     if (!$bPermissions) {
         /*$sql = "SELECT SUM((o.rating = 1)::int) as p, SUM((o.rating = 0)::int) as n, SUM((o.rating = -1)::int) as m
           FROM opinions o
           INNER JOIN users u ON u.uid = o.fromuser_id 
           WHERE o.touser_id = ?i AND u.is_banned::integer = 0";*/
         $sql = "SELECT ops_frl_plus + ops_emp_plus as p, ops_emp_null + ops_frl_null as n, ops_emp_minus + ops_frl_minus as m FROM users_counters WHERE user_id = ?";
         $ret['users'] = $DB->row($sql, $user_id);
         /**
          * @deprecated #0017304 
          */
         if (in_array('all', $fromType) || in_array('frl', $fromType) || in_array('total', $fromType)) {
             $sql = "SELECT ops_frl_plus + ops_emp_plus as p, ops_frl_null + ops_emp_null as n, ops_frl_minus + ops_emp_minus as m FROM users_counters WHERE user_id = ?";
             if ($res = $DB->query($sql, $user_id)) {
                 $ret['all'] = pg_fetch_assoc($res);
             }
         }
         if (in_array('emp', $fromType) || in_array('frl', $fromType)) {
             $sql = "SELECT ops_emp_plus as p, ops_emp_null as n, ops_emp_minus as m FROM users_counters WHERE user_id = ?";
             if ($res = $DB->query($sql, $user_id)) {
                 $ret['emp'] = pg_fetch_assoc($res);
             }
         }
         if (in_array('frl', $fromType)) {
             $ret['frl']['p'] = $ret['all']['p'] - $ret['emp']['p'];
             $ret['frl']['n'] = $ret['all']['n'] - $ret['emp']['n'];
             $ret['frl']['m'] = $ret['all']['m'] - $ret['emp']['m'];
         }
     } else {
         $sql = "SELECT SUM((o.rating = 1)::int) as p, SUM((o.rating = 0)::int) as n, SUM((o.rating = -1)::int) as m\n                    FROM opinions o\n                    INNER JOIN users u ON u.uid = o.fromuser_id \n                    WHERE o.touser_id = ?i AND u.is_banned::integer = 0";
         $ret['users'] = $DB->row($sql, $user_id);
         /**
          * @deprecated #0017304 
          */
         if (in_array('all', $fromType) || in_array('frl', $fromType) || in_array('total', $fromType)) {
             $sql = 'SELECT SUM((o.rating = 1)::int) as p, SUM((o.rating = 0)::int) as n, SUM((o.rating = -1)::int) as m
                 FROM opinions o
                 INNER JOIN freelancer u ON u.uid = o.fromuser_id
                 WHERE o.touser_id = ?';
             if ($res = $DB->query($sql, $user_id)) {
                 $ret['frl'] = pg_fetch_assoc($res);
             }
         }
         if (in_array('all', $fromType) || in_array('emp', $fromType) || in_array('total', $fromType)) {
             $sql = 'SELECT SUM((o.rating = 1)::int) as p, SUM((o.rating = 0)::int) as n, SUM((o.rating = -1)::int) as m
                 FROM opinions o
                 INNER JOIN employer u ON u.uid = o.fromuser_id 
                 WHERE o.touser_id = ?';
             if ($res = $DB->query($sql, $user_id)) {
                 $ret['emp'] = pg_fetch_assoc($res);
             }
         }
         if (in_array('emp', $fromType) || in_array('frl', $fromType)) {
             $sql = "SELECT ops_emp_plus as p, ops_emp_null as n, ops_emp_minus as m FROM users_counters WHERE user_id = ?";
             if ($res = $DB->query($sql, $user_id)) {
                 $ret['emp'] = pg_fetch_assoc($res);
             }
         }
         if (in_array('all', $fromType) || in_array('total', $fromType)) {
             $ret['all']['p'] = $ret['frl']['p'] + $ret['emp']['p'];
             $ret['all']['n'] = $ret['frl']['n'] + $ret['emp']['n'];
             $ret['all']['m'] = $ret['frl']['m'] + $ret['emp']['m'];
         }
     }
     if (in_array('norisk', $fromType) || in_array('total', $fromType)) {
         $sql = "SELECT sbr_opi_plus as p, sbr_opi_null as n, sbr_opi_minus as m FROM users_counters WHERE user_id = ?";
         if ($res = $DB->query($sql, $user_id)) {
             $ret['norisk'] = pg_fetch_assoc($res);
         }
     }
     if (in_array('total', $fromType)) {
         $ret['total']['p'] = $ret['all']['p'] + $ret['norisk']['p'];
         $ret['total']['n'] = $ret['all']['n'] + $ret['norisk']['n'];
         $ret['total']['m'] = $ret['all']['m'] + $ret['norisk']['m'];
     }
     if (in_array('my', $fromType)) {
         $sql = "SELECT SUM((o.rating = 1)::int) as p, SUM((o.rating = 0)::int) as n, SUM((o.rating = -1)::int) as m\n                      FROM opinions o\n                    INNER JOIN\n                      users u\n                        ON u.uid = o.touser_id\n                        " . ($bPermissions ? '' : ' AND u.is_banned::integer = 0 ') . "\n                     WHERE o.active = true\n                       AND o.fromuser_id = ?\n                      ";
         if ($res = $DB->query($sql, $user_id)) {
             $ret['my'] = pg_fetch_assoc($res);
         }
     }
     if (in_array('tu_orders', $fromType) || in_array('total', $fromType)) {
         $sql = "SELECT \n                        tu_orders_plus as p, \n                        0 as n, \n                        tu_orders_minus as m \n                    FROM users_counters \n                    WHERE user_id = ?";
         if ($res = $DB->query($sql, $user_id)) {
             $ret['tu_orders'] = pg_fetch_assoc($res);
         }
     }
     if (in_array('total', $fromType)) {
         $ret['total']['p'] = $ret['total']['p'] + $ret['tu_orders']['p'];
         $ret['total']['n'] = $ret['total']['n'] + $ret['tu_orders']['n'];
         $ret['total']['m'] = $ret['total']['m'] + $ret['tu_orders']['m'];
     }
     if (in_array('project_feedbacks', $fromType) || in_array('total', $fromType)) {
         $ext = $user_id == get_uid(false) || is_moder() ? '_ext' : '';
         $sql = "SELECT \n                        projects_fb{$ext}_plus as p, \n                        0 as n, \n                        projects_fb{$ext}_minus as m \n                    FROM users_counters \n                    WHERE user_id = ?";
         if ($res = $DB->query($sql, $user_id)) {
             $ret['project_feedbacks'] = pg_fetch_assoc($res);
         }
     }
     if (in_array('total', $fromType)) {
         $ret['total']['p'] = $ret['total']['p'] + $ret['project_feedbacks']['p'];
         $ret['total']['n'] = $ret['total']['n'] + $ret['project_feedbacks']['n'];
         $ret['total']['m'] = $ret['total']['m'] + $ret['project_feedbacks']['m'];
     }
     return $ret;
 }
예제 #3
0
                ?>
" class="public_red_normal">разблокировать деньги</a>
			<?php 
            }
            ?>
			
			<br><br>
			<?php 
            if (hasPermissions('users')) {
                ?>
 Права: 
			<a href=".?action=chmoder&id=<?php 
                echo $user['uid'];
                ?>
" class="blue"><?php 
                echo is_moder($user['role']) ? "снять" : "дать";
                ?>
 модератора</a> |
			<a href=".?action=chredact&id=<?php 
                echo $user['uid'];
                ?>
" class="blue"><?php 
                echo is_redactor($user['role']) ? "снять" : "дать";
                ?>
 редактора</a>
            <?php 
                if ($user['active'] == 'f') {
                    ?>
 | <a href="/siteadmin/users/?action=activate&amp;login=<?php 
                    echo $user['login'];
                    ?>
예제 #4
0
 /**
  * Возвращает информацию по всем отзывам, оставленным определенному пользователю.
  *
  * @param integer $uid    ИД пользователя
  * @param integer $type   false: юзер -- фрилансер, true -- работодатель.
  * @param integer $sort   Сортировка по виду отзыва (1 - положительный, 0 - нейтральные, -1 - отрицательные, false - нет сортировки)
  * @param integer $period           период за который отображать отзывы: 0 - все, 1 - за год, 2 - за пол года, 3 - за месяц
  * @param integer $new_format группировать или нет отзывы по sbr_id (для нового формата вывода)
  * @param bool $deleted - если false, то не возвращаются рекомендации помеченые как удаленные
  * 
  * @return array Данные выборки
  */
 function getUserFeedbacks($uid, $type, $sort = false, $period = 0, $new_format = true, $deleted = true)
 {
     $u_col = $type ? 'emp_id' : 'frl_id';
     $a_pfx = $type ? 'frl_' : 'emp_';
     $a_tbl = $type ? 'freelancer' : 'employer';
     switch ($sort) {
         case 1:
             $rating = 1;
             break;
         case 2:
             $rating = 0;
             break;
         case 3:
             $rating = -1;
             break;
         default:
             $rating = false;
             break;
     }
     switch ($period) {
         case 1:
             $periodSQL = "AND sf.posted_time > NOW()-interval '1 year'";
             $periodSQL2 = "AND pa.create_date > NOW()-interval '1 year'";
             $periodSQL3 = "AND fb.posted_time > NOW()-interval '1 year'";
             $periodSQL4 = "AND pfb.posted_time > NOW()-interval '1 year'";
             break;
         case 2:
             $periodSQL = "AND sf.posted_time > NOW()-interval '6 month'";
             $periodSQL2 = "AND pa.create_date > NOW()-interval '6 month'";
             $periodSQL3 = "AND fb.posted_time > NOW()-interval '6 month'";
             $periodSQL4 = "AND pfb.posted_time > NOW()-interval '6 month'";
             break;
         case 3:
             $periodSQL = "AND sf.posted_time > NOW()-interval '1 month'";
             $periodSQL2 = "AND pa.create_date > NOW()-interval '1 month'";
             $periodSQL3 = "AND fb.posted_time > NOW()-interval '1 month'";
             $periodSQL4 = "AND pfb.posted_time > NOW()-interval '1 month'";
             break;
         default:
             $periodSQL = $periodSQL2 = $periodSQL3 = $periodSQL4 = '';
     }
     $deletedCondition = !$deleted ? ' AND sf.deleted IS NOT TRUE' : '';
     $deletedCondition2 = !$deleted ? ' AND fb.deleted = FALSE' : '';
     $deletedCondition3 = !$deleted ? ' AND pfb.deleted = FALSE' : '';
     $sql = "\n          SELECT \n            0 AS opinion_type, -- Тип отзыва в обьединении\n            sf.id as id, \n            (sf.id * 2 + 1)::text as uniq_id, -- Если не используется как число предлагаю добавлять opinion_type\n            s.id as sbr_id, \n            s.name as sbr_name, \n            s.frl_id, \n            s.emp_id, \n            s.project_id,\n            ss.id as stage_id, \n            ss.name as stage_name, \n            ss.status as stage_status, \n            ss.created as stage_created, \n            ss.closed_time as stage_closed,\n            ss.category, \n            ss.sub_category, \n            sf.rating AS sbr_rating, \n            sf.is_new_rating, \n            sf.update_time, \n            sf.posted_time,\n            u.uid as fromuser_id, \n            sf.a_rate, \n            sf.p_rate, \n            sf.n_rate, \n            sf.posted_time as post_time, \n            sf.descr, \n            {$uid} as touser_id, \n            u.reg_date as ago, \n            u.login, \n            u.uname, \n            u.usurname, \n            u.role, \n            u.photo, \n            u.is_pro,\n            u.is_profi,\n            u.is_pro_test, \n            u.is_team, \n            ss.num, \n            0 as is_payed, \n            u.is_banned, \n            s.scheme_id, \n            s.scheme_type,\n            sfc.user_id as comm_user_id, \n            sfc.comment as comm_text, \n            sfc.date_create as comm_date_create, \n            sfc.id as comm_id,\n            NULL::boolean as hidden,\n            0 AS kind,\n            0 AS type\n          FROM sbr s\n          INNER JOIN sbr_stages ss ON ss.sbr_id = s.id\n          INNER JOIN sbr_feedbacks sf ON sf.id = ss.{$a_pfx}feedback_id\n          INNER JOIN {$a_tbl} u ON u.uid = s.{$a_pfx}id\n          LEFT JOIN sbr_feedbacks_comments sfc ON sfc.feedback_id = sf.id\n          WHERE \n            s.{$u_col} = {$uid} \n            " . ($rating !== false ? " AND sf.rating = {$rating}" : "") . "    \n            {$periodSQL} {$deletedCondition}\n          \n          UNION ALL\n          \n          SELECT \n            1 AS opinion_type,\n            pa.id as id, \n            (pa.id * 2)::text as uniq_id, \n            pa.id as sbr_id, \n            NULL::character as sbr_name, \n            pa.user_to frl_id, \n            pa.user_from as emp_id, \n            NULL::integer as project_id,\n            NULL::integer as stage_id, \n            NULL::character as stage_name, \n            NULL::integer as stage_status, \n            pa.create_date as stage_created,\n            NULL::timestamp without time zone as stage_closed, \n            NULL::integer as category, \n            NULL::integer as sub_category, \n            1 as sbr_rating, \n            NULL::boolean as is_new_rating,\n            pa.accept_date as update_time, \n            pa.create_date as posted_time,\n            pa.user_from as fromuser_id, \n            NULL::integer as a_rate, \n            NULL::integer as p_rate, \n            NULL::integer as n_rate, \n            pa.create_date as post_time, \n            pa.msgtext as descr,\n            pa.user_to as touser_id, \n            e.reg_date as ago, \n            e.login, \n            e.uname, \n            e.usurname, \n            e.role, e.photo, \n            e.is_pro, \n            e.is_profi,\n            e.is_pro_test, \n            e.is_team, \n            0 as num, \n            1 as is_payed, \n            e.is_banned, \n            NULL as scheme_id, \n            NULL as scheme_type,\n            0 as comm_user_id, \n            '' as comm_text, \n            '1970-01-01' as comm_date_create, \n            0 as comm_id,\n            NULL::boolean as hidden,\n            0 AS kind,\n            0 AS type\n          FROM paid_advices pa\n          INNER JOIN users e ON e.uid = pa.user_from\n          WHERE \n            pa.user_to = {$uid} AND pa.status = " . paid_advices::STATUS_PAYED . " AND pa.op_id IS NOT NULL\n            " . ($rating !== false && $rating != 1 ? " AND 1 = 0" : "") . "    \n            {$periodSQL2}    \n\n          UNION ALL\n\n          SELECT \n            2 AS opinion_type,-- Тип отзыва в обьединении\n            fb.id as id, \n            (fb.id || '-2') as uniq_id,-- Если не используется как число предлагаю добавлять opinion_type\n            fb.id as sbr_id, \n            o.title as sbr_name, \n            o.frl_id, \n            o.emp_id, \n            o.tu_id as project_id,\n            NULL::integer as stage_id, \n            NULL::character as stage_name, \n            NULL::integer as stage_status, \n            o.date as stage_created,\n            o.close_date as stage_closed, \n            NULL::integer as category, \n            NULL::integer as sub_category, \n            fb.rating as sbr_rating, \n            NULL::boolean as is_new_rating,\n            o.accept_date as update_time, \n            fb.posted_time as posted_time,\n            u.uid as fromuser_id, \n            NULL::integer as a_rate, \n            NULL::integer as p_rate, \n            NULL::integer as n_rate, \n            fb.posted_time as post_time, \n            fb.feedback as descr,\n            u.uid as touser_id, \n            u.reg_date as ago, \n            u.login, \n            u.uname, \n            u.usurname, \n            u.role, \n            u.photo, \n            u.is_pro, \n            u.is_profi,\n            u.is_pro_test, \n            u.is_team, \n            o.order_price as num, \n            0 as is_payed, \n            u.is_banned, \n            NULL as scheme_id, \n            NULL as scheme_type,\n            fbc.user_id as comm_user_id, \n            fbc.comment as comm_text, \n            fbc.date_create as comm_date_create, \n            fbc.id as comm_id,\n            NULL::boolean as hidden,\n            0 AS kind,\n            o.type AS type\n          FROM tservices_orders_feedbacks AS fb \n          INNER JOIN tservices_orders AS o ON o.{$a_pfx}feedback_id = fb.id\n          INNER JOIN {$a_tbl} u ON u.uid = o.{$a_pfx}id \n          LEFT JOIN tservices_orders_feedbacks_comments fbc ON fbc.feedback_id = fb.id\n          WHERE\n            o.{$u_col} = {$uid} \n            " . ($rating !== false ? " AND fb.rating = {$rating}" : "") . " \n            {$periodSQL3} \n            {$deletedCondition2}\n\n        UNION ALL\n          \n          SELECT \n            3 AS opinion_type,-- Тип отзыва в обьединении\n            pfb.id as id, \n            (pfb.id || '-3') as uniq_id,\n            p.id as sbr_id, \n            p.name as sbr_name, \n            po.user_id as frl_id,\n            p.user_id as emp_id, \n            p.id as project_id,\n            NULL::integer as stage_id, \n            NULL::character as stage_name, \n            NULL::integer as stage_status, \n            po.post_date as stage_created,\n            p.close_date as stage_closed,\n            NULL::integer as category,\n            NULL::integer as sub_category,\n            pfb.rating as sbr_rating,\n            NULL::boolean as is_new_rating,\n            NULL::timestamp as update_time,  --TODO\n            pfb.posted_time as posted_time,\n            u.uid as fromuser_id,\n            NULL::integer as a_rate, \n            NULL::integer as p_rate, \n            NULL::integer as n_rate, \n            pfb.posted_time as post_time, \n            pfb.feedback as descr,\n            u.uid as touser_id, \n            u.reg_date as ago, \n            u.login, \n            u.uname, \n            u.usurname, \n            u.role, \n            u.photo, \n            u.is_pro, \n            u.is_profi,\n            u.is_pro_test, \n            u.is_team, \n            p.cost as num, \n            0 as is_payed, \n            u.is_banned, \n            NULL as scheme_id, \n            NULL as scheme_type,\n            NULL as comm_user_id, \n            NULL as comm_text, \n            NULL as comm_date_create, \n            NULL as comm_id,\n            pfb.show='f' as hidden,\n            p.kind AS kind,\n            0 AS type\n          FROM projects_feedbacks AS pfb \n          INNER JOIN projects AS p ON p.id = pfb.project_id\n          INNER JOIN projects_offers AS po ON p.id = po.project_id AND p.exec_id = po.user_id\n          INNER JOIN {$a_tbl} u ON u.uid = pfb.user_id \n          WHERE\n            " . ($type ? 'p.user_id' : 'po.user_id') . " = {$uid} \n            " . ($rating !== false ? " AND pfb.rating = {$rating}" : "") . " \n            {$periodSQL4} \n            {$deletedCondition3}\n            AND (pfb.show = TRUE OR p.user_id=" . get_uid(false) . " OR p.exec_id=" . get_uid(false) . " OR " . (is_moder() ? 'TRUE' : 'FALSE') . ")\n          ORDER BY posted_time DESC, id ASC, num\n        ";
     //$GLOBALS['DB']->query($sql);
     if ($res = pg_query(DBConnect(), $sql)) {
         $data = pg_fetch_all($res);
     }
     if (!count($data)) {
         return null;
     }
     if (!$new_format) {
         return $data;
     }
     return self::groupBySBRId($data);
 }