diff --git a/api.php b/api.php index 6769ca87..fe387709 100644 --- a/api.php +++ b/api.php @@ -81,9 +81,6 @@ Utils::validateAPIKey(); checkRemovableProjects(); break; - case 'setFavorite': - setFavorite(); - break; case 'getBonusHistory': getBonusHistory(); break; @@ -625,58 +622,6 @@ function dump_row_values($row) { return $dump; } -function setFavorite() { - if ( !isset($_REQUEST['favorite_user_id']) || - !isset($_REQUEST['newVal']) ) { - echo json_encode(array( 'error' => "Invalid parameters!")); - } - $userId = Session::uid(); - if ($userId > 0) { - Utils::initUserById($userId); - $user = new User(); - $user->findUserById( $userId ); - - $favorite_user_id = (int) $_REQUEST['favorite_user_id']; - $newVal = (int) $_REQUEST['newVal']; - $users_favorites = new Users_Favorite(); - $res = $users_favorites->setMyFavoriteForUser($userId, $favorite_user_id, $newVal); - if ($res == "") { - // send chat if user has been marked a favorite - $favorite_user = new User(); - $favorite_user->findUserById($favorite_user_id); - if ($newVal == 1) { - - $resetUrl = SECURE_SERVER_URL . 'user/' . $favorite_user_id ; - $resetUrl = '' . $resetUrl . ''; - $data = array(); - $data['link'] = $resetUrl; - $nick = $favorite_user->getNickname(); - if (! Utils::sendTemplateEmail($favorite_user->getUsername(), 'trusted', $data)) { - error_log("setFavorite: Utils::send_email failed on favorite notification"); - } - - // get favourite count - $count = $users_favorites->getUserFavoriteCount($favorite_user_id); - if ($count > 0) { - if ($count == 1) { - $message = "**{$count}** person"; - } else { - $message = "**{$count}** people"; - } - $journal_message = '@' . $nick . ' is now trusted by ' . $message . '!'; - //sending journal notification - Utils::systemNotification(stripslashes($journal_message)); - } - } - echo json_encode(array( 'return' => "Trusted saved.")); - } else { - echo json_encode(array( 'error' => $res)); - } - } else { - echo json_encode(array( 'error' => "You must be logged in!")); - } -} - function getBonusHistory() { checkLogin(); @@ -820,7 +765,7 @@ function getUserList() { $limit = 30; $page = isset($_REQUEST["page"])?intval($_REQUEST["page"]) : 1; $letter = isset($_REQUEST["letter"]) ? mysql_real_escape_string(trim($_REQUEST["letter"])) : ""; - $order = !empty($_REQUEST["order"]) ? mysql_real_escape_string(trim($_REQUEST["order"])) : "earnings30"; + $order = !empty($_REQUEST["order"]) ? mysql_real_escape_string(trim($_REQUEST["order"])) : "jobs_count"; $order_dir = isset($_REQUEST["order_dir"]) ? mysql_real_escape_string(trim($_REQUEST["order_dir"])) : "DESC"; $active = isset( $_REQUEST['active'] ) && $_REQUEST['active'] == 'TRUE' ? 'TRUE' : 'FALSE'; $myfavorite = isset( $_REQUEST['myfavorite'] ) && $_REQUEST['myfavorite'] == 'TRUE' ? 'TRUE' : 'FALSE'; @@ -861,32 +806,20 @@ function getUserList() { if( $active == 'FALSE' ) { $query = " SELECT `id`, `nickname`,`added` AS `joined`, `budget`, - IFNULL(`creators`.`count`,0) + IFNULL(`mechanics`.`count`,0) AS `jobs_count`, - IFNULL(`earnings`.`sum`,0) AS `earnings`, - IFNULL(`earnings30`.`sum`,0) AS `earnings30`, - IFNULL(`rewarder`.`sum`,0)AS `rewarder` + IFNULL(`creators`.`count`,0) + IFNULL(`mechanics`.`count`,0) AS `jobs_count` FROM `".USERS."` LEFT JOIN (SELECT `mechanic_id`, COUNT(`mechanic_id`) AS `count` FROM `" . WORKLIST . "` WHERE (`status` IN ('In Progress', 'QA Ready', 'Review', 'Merged', 'Done')) GROUP BY `mechanic_id`) AS `mechanics` ON `".USERS."`.`id` = `mechanics`.`mechanic_id` LEFT JOIN (SELECT `creator_id`, COUNT(`creator_id`) AS `count` FROM `" . WORKLIST . "` WHERE (`status` IN ('In Progress', 'QA Ready', 'Review', 'Merged', 'Done')) AND `creator_id` != `mechanic_id` GROUP BY `creator_id`) AS `creators` ON `".USERS."`.`id` = `creators`.`creator_id` - LEFT JOIN (SELECT `user_id`, SUM(amount) AS `sum` FROM `".FEES."` WHERE $sfilter AND `paid` = 1 AND `withdrawn`=0 AND (`rewarder`=1 OR `bonus`=1) GROUP BY `user_id`) AS `rewarder` ON `".USERS."`.`id` = `rewarder`.`user_id` - LEFT JOIN (SELECT `user_id`, SUM(amount) AS `sum` FROM `".FEES."` WHERE $sfilter AND `withdrawn`=0 AND `expense`=0 AND `paid` = 1 AND `paid_date` IS NOT NULL GROUP BY `user_id`) AS `earnings` ON `".USERS."`.`id` = `earnings`.`user_id` - LEFT JOIN (SELECT `user_id`, SUM(amount) AS `sum` FROM `".FEES."` WHERE `withdrawn`=0 AND `paid` = 1 AND `paid_date` IS NOT NULL AND `paid_date` > DATE_SUB(NOW(), INTERVAL 30 DAY) AND `expense`=0 GROUP BY `user_id`) AS `earnings30` ON `".USERS."`.`id` = `earnings30`.`user_id` LEFT JOIN (SELECT `user_id`, SUM(amount) AS `sum` FROM `".FEES."` WHERE ($sfilter AND `withdrawn`=0 AND `paid` = 1) AND `expense`=1 GROUP BY `user_id`) AS `expenses_billed` ON `".USERS."`.`id` = `expenses_billed`.`user_id` WHERE `nickname` REGEXP '^$letter' AND `is_active` = 1 $myfavorite_cond ORDER BY `$order` $order_dir LIMIT " . ($page-1)*$limit . ",$limit"; } else if( $active == 'TRUE' ) { $query = " SELECT `id`, `nickname`,`added` AS `joined`, `budget`, - IFNULL(`creators`.`count`,0) + IFNULL(`mechanics`.`count`,0) AS `jobs_count`, - IFNULL(`earnings`.`sum`,0) AS `earnings`, - IFNULL(`earnings30`.`sum`,0) AS `earnings30`, - IFNULL(`rewarder`.`sum`,0)AS `rewarder` + IFNULL(`creators`.`count`,0) + IFNULL(`mechanics`.`count`,0) AS `jobs_count` FROM `".USERS."` LEFT JOIN (SELECT `user_id`,MAX(`date`) AS `date` FROM `".FEES."` WHERE `paid` = 1 AND `amount` != 0 AND `withdrawn` = 0 AND `expense` = 0 GROUP BY `user_id`) AS `dates` ON `".USERS."`.id = `dates`.user_id LEFT JOIN (SELECT `mechanic_id`, COUNT(`mechanic_id`) AS `count` FROM `" . WORKLIST . "` WHERE (`status` IN ('In Progress', 'QA Ready', 'Review', 'Merged', 'Done')) GROUP BY `mechanic_id`) AS `mechanics` ON `".USERS."`.`id` = `mechanics`.`mechanic_id` LEFT JOIN (SELECT `creator_id`, COUNT(`creator_id`) AS `count` FROM `" . WORKLIST . "` WHERE (`status` IN ('In Progress', 'QA Ready', 'Review', 'Merged', 'Done')) AND `creator_id` != `mechanic_id` GROUP BY `creator_id`) AS `creators` ON `".USERS."`.`id` = `creators`.`creator_id` - LEFT JOIN (SELECT `user_id`, SUM(amount) AS `sum` FROM `".FEES."` WHERE $sfilter AND `paid` = 1 AND `withdrawn`=0 AND (`rewarder`=1 OR `bonus`= 1) GROUP BY `user_id`) AS `rewarder` ON `".USERS."`.`id` = `rewarder`.`user_id` - LEFT JOIN (SELECT `user_id`, SUM(amount) AS `sum` FROM `".FEES."` WHERE $sfilter AND `withdrawn`=0 AND `expense`=0 AND `paid` = 1 AND `paid_date` IS NOT NULL GROUP BY `user_id`) AS `earnings` ON `".USERS."`.`id` = `earnings`.`user_id` - LEFT JOIN (SELECT `user_id`, SUM(amount) AS `sum` FROM `".FEES."` WHERE `withdrawn`=0 AND `paid` = 1 AND `paid_date` IS NOT NULL AND `paid_date` > DATE_SUB(NOW(), INTERVAL 30 DAY) AND `expense`=0 GROUP BY `user_id`) AS `earnings30` ON `".USERS."`.`id` = `earnings30`.`user_id` LEFT JOIN (SELECT `user_id`, SUM(amount) AS `sum` FROM `".FEES."` WHERE ($sfilter AND `withdrawn`=0 AND `paid` = 1) AND `expense`=1 GROUP BY `user_id`) AS `expenses_billed` ON `".USERS."`.`id` = `expenses_billed`.`user_id` WHERE `date` > DATE_SUB(NOW(), INTERVAL $sfilter DAY) AND `nickname` REGEXP '^$letter' AND `is_active` = 1 $myfavorite_cond ORDER BY `$order` $order_dir LIMIT " . ($page-1)*$limit . ",$limit"; } diff --git a/controllers/User.php b/controllers/User.php index ec67fc21..ca8780cf 100644 --- a/controllers/User.php +++ b/controllers/User.php @@ -567,55 +567,6 @@ public function budgetHistory($id, $page = 1, $itemsPerPage = 10) { echo json_encode($user->budgetHistory($giver_id, $page, $itemsPerPage)); } - public function loves($id, $page = 1, $itemsPerPage = 5) { - $this->view = null; - $user = User::find($id); - $page = (is_numeric($page) ? $page : 1); - $itemsPerPage = (is_numeric($itemsPerPage) ? $itemsPerPage : 5); - echo json_encode($user->loves($page, $itemsPerPage)); - } - - public function sendLove($to) { - $this->view = null; - try { - if (!Session::uid()) { - throw new Exception('Must be logged in to Send Love!'); - } - $from = User::find(Session::uid()); - - $to = User::find($to); - if (!$to->getId()) { - throw new Exception('Not a valid user'); - } - - $love_message = $_POST['love_message']; - if (empty($love_message)) { - throw new Exception('Message field is mandatory'); - } - - if (!$from->sendLove($to, $love_message)) { - throw new Exception('Could not send love'); - } - - $from_nickname = $from->getNickname(); - $message = $_POST['love_message']; - Utils::sendTemplateEmail($to->getUsername(), 'love-received', array( - 'from_nickname'=> $from_nickname, - 'message' => $message - )); - - echo json_encode(array( - 'success' => true, - 'message' => 'Love sent' - )); - } catch (Exception $e) { - echo json_encode(array( - 'success' => false, - 'message' => $e->getMessage() - )); - } - } - public function isUSCitizen($id) { $this->view = null; try { diff --git a/css/favorites.css b/css/favorites.css deleted file mode 100644 index fa7d19f4..00000000 --- a/css/favorites.css +++ /dev/null @@ -1,72 +0,0 @@ -.favoriteIcon.favorite0 { - display: none; -} - -/** - * Favorite star inside the mission list - */ -.table-missions .favoriteIcon { - height: 12px; - width: 12px; - vertical-align: middle; -} - -.favorite_count.favorited { - background-position: 132px 0 !important; -} - -.favorite_count.favorited:hover { - background-position: 0 0 !important; -} - -.favorite_count.notfavorited:hover { - background-position: 88px 0 !important; -} - -.favorite_user.favorited { - background-image: url('../images/wl-icons/star-dark.png'); - background-image: url('../images/wl-icons/star-dark.svg'); - background-repeat: no-repeat; -} - -.favorite_user.myfavorite { - background-image: url('../images/wl-icons/star-dark.png'); - background-image: url('../images/wl-icons/star-dark.svg'); - background-repeat: no-repeat; -} - -.favorite_user.favorited:hover { - background-image: url('../images/wl-icons/star-remove.png'); - background-image: url('../images/wl-icons/star-remove.svg'); - background-repeat: no-repeat; -} - -.favorite_user.myfavorite:hover { - background-image: url('../images/wl-icons/star-remove.png'); - background-image: url('../images/wl-icons/star-remove.svg'); - background-repeat: no-repeat; -} - -.favorite_user.notfavorited:hover { - background-image: url('../images/wl-icons/star-add.png'); - background-image: url('../images/wl-icons/star-add.svg'); - background-repeat: no-repeat; -} - -.favorite_user.notmyfavorite:hover { - background-image: url('../images/wl-icons/star-add.png'); - background-image: url('../images/wl-icons/star-add.svg'); - background-repeat: no-repeat; -} - -.favorite_user.notmyfavorite { - background-image: url('../images/wl-icons/star.png'); - background-image: url('../images/wl-icons/star.svg'); - background-repeat: no-repeat; -} - -.favorite_user.notfavorited { - background-image: url('../images/wl-icons/star.png'); - background-image: url('../images/wl-icons/star.svg'); - background-repeat: no-repeat; -} \ No newline at end of file diff --git a/css/userinfo.css b/css/userinfo.css index 0de1d0e1..f80c74c8 100644 --- a/css/userinfo.css +++ b/css/userinfo.css @@ -179,7 +179,7 @@ body > .container-fluid h3 { font-size: 14px; margin-top: 21px; line-height: 17px; - padding-bottom: 12px; + padding-bottom: 12px; } #globalinfo > div > .info-label:first-child a, @@ -267,84 +267,6 @@ p.bottom { top: 6em; } -#love input { - background: none; - padding-left: 160px; - padding-right: 0; - width: auto; - font-size: 12px !important; - font-weight: normal !important; - color: #88AAB0 !important; - border: 0 none; - position: relative; - top: 2px; -} - -.loveTitle { - border-bottom: 2px solid #E1E8EA; - padding-bottom: 6px; - width: 415px !important; -} - -.loveTitle a { - padding-left: 26px; -} - -#user-loves { - padding: .5em 0 .5em; - color: #6E6E6E; -} - -#user-loves > * { - display: inline; - line-height: 110%; - font-size: 1em; -} - -#user-loves cite:before { - content: '\201c'; -} - -#user-loves cite:after { - content: '\201d'; -} - -#user-loves h6 { - margin-top: .4em; - margin-bottom: .2em; -} - -#user-loves h6, -#user-loves h6 a { - color: #8B8B8B; -} - -#user-loves h6 span { - color: #999; -} - -#user-loves h6 a { - text-decoration: underline; -} - -#user-loves h6:after { - content: ''; - display: block; - padding-bottom: 10px; -} - -#user-loves h6:before { - padding-right: 60px; -} -#user-loves + a { - font-size: 12px; - font-weight: normal; - top: 10px; - padding-bottom: 20px; - position: relative; - color: #8B8B8B; -} - .reviewTitle { font-weight: normal !important; padding-left: 0 !important; @@ -477,14 +399,14 @@ p.bottom { .userName { color: #007F7C; font-size: 28px; - line-height: 60px; + line-height: 30px; vertical-align: top; padding: 6px 11px; width: 293px; font-family:Helvetica Neue, Helvetica, Arial, sans-serif; font-weight: bold; display: inline-block; - margin-bottom: 45px; + margin-top: 58px; white-space: nowrap; } @@ -511,41 +433,15 @@ p.bottom { line-height: 22px; vertical-align: top; padding: 6px 0; - border-bottom: 2px solid #E1E8EA; - border-top: 2px solid #e1e8ea; width: 100%; font-weight: bold; + margin-top: 69px; } .profileContactFavorite span{ font-weight: normal; } -.profileContactFavorite, -.profileInfoFavorite { - margin-top: 61px; -} - -.profileInfoFavorite { - color: #666; - font-size: 12px; - line-height: 22px; - vertical-align: top; - padding: 6px 11px; - border-bottom: 2px solid #E1E8EA; - border-top: 2px solid #e1e8ea; - width: 310px; - font-weight: bold; - display: inline-block; - position: absolute; - top: 0px; - right: 0px; -} - -.profileInfoFavorite>img { - vertical-align: middle; -} - .favorite_user, .favorite_curr_user { height: 20px; @@ -729,11 +625,11 @@ form#roles ul li { margin: 0; } - #jobs-table tr > td:first-child, #loves-table tr > td:first-child { + #jobs-table tr > td:first-child { max-width: 125px; } form#roles ul li { display: block; } -} \ No newline at end of file +} diff --git a/js/favorites.js b/js/favorites.js deleted file mode 100644 index 949daf46..00000000 --- a/js/favorites.js +++ /dev/null @@ -1,118 +0,0 @@ -var WLFavorites = { - favMissionText: null, - init: function(containerID, favorite_user_id, fav_user_nickname) { - $('.favorite_user, .favorite_count', $("#" + containerID)).click(function(){ - var newVal = ($(this).hasClass("myfavorite")) ? 0 : 1; - WLFavorites.setFavorite(favorite_user_id, newVal, containerID, null, fav_user_nickname); - }); - - var favCount = $('.profileFavoriteText').attr('data-favorite-count'); - var isMyFav = false; - if ($('.favorite_user').hasClass('myfavorite')) { - isMyFav = true; - } - - var favText = WLFavorites.getFavoriteText(favCount, isMyFav, 'Trusted '); - - $('.profileFavoriteText').html(favText); - }, - setFavorite: function( favorite_user_id, newVal, containerID, fAfter, fav_user_nickname ) { - /* - * remove the .favorite_count - */ - $.ajax({ - type: 'POST', - url: 'api.php', - data: { - action: 'setFavorite', - favorite_user_id: favorite_user_id, - newVal: newVal - }, - dataType: 'json', - success: function(json) { - if ((json === null) || (json.error)) { - var message="Error returned - f1. "; - if (json !== null) { - message = message + json.error; - } - alert(message); - return; - } - var fav = parseInt($('.profileFavoriteText').attr('data-favorite-count')); - if (newVal == 1) { - $('.profileFavoriteText').attr('data-favorite-count', fav + 1); - var favText = WLFavorites.getFavoriteText(fav + 1, true, 'Trusted '); - $('.profileFavoriteText').html(favText); - $(".favorite_user, .favorite_count") - .removeClass("notmyfavorite") - .addClass("myfavorite") - .attr("title", "Remove " + fav_user_nickname + " from your trusted by. (don't worry it's anonymous)"); - } else { - $('.profileFavoriteText').attr('data-favorite-count', fav - 1); - var favText = WLFavorites.getFavoriteText(fav - 1, false, 'Trusted '); - $('.profileFavoriteText').html(favText); - $(".favorite_user, .favorite_count") - .removeClass("myfavorite") - .addClass("notmyfavorite") - .attr("title", "Add " + fav_user_nickname + " as one of your trusted people."); - - } - if (fAfter) { - fAfter(true); - } - } - - }); - }, - getFavoriteIcon: function(favoriteEnabled, objectId, type) { - if (type == 'mission') { - toggleClass = 'favoriteMissionIconFor' + objectId; - } else { - toggleClass = 'favoriteIconFor' + objectId; - } - var imageFavorite = '', - imageFavoriteClass = 'favorite0', - imageFavoritePath = 'images/white_star.png'; - if (favoriteEnabled == 1) { - imageFavoriteClass = 'favorite1'; - if (type == 'userlist') { - imageFavoritePath = 'images/peopleFavorite.png'; - } else { - imageFavoritePath = 'images/yellow_star.png'; - } - } - imageFavorite = 'Favorite'; - return imageFavorite; - }, - // function that returns the appropriate favorite text for users - // and for missions. Takes the number of favorites and a boolean for - // that a true if the user/mission is a favorite of the currently - // logged in user. - getFavoriteText: function(favCount, isMyFav, favText) { - favText = typeof(favText) != 'undefined' ? favText : ''; - - var pluralize = 'people'; - if (favCount == 1) { - pluralize = 'person'; - } - - // if there are no favorites - if (favCount == 0) { - favText += 'by no one... for now!'; - } else if (isMyFav) { - if (favCount == 1) { - favText += 'by you'; - } else /* if the user is not the only user to favorite */ { - if (favCount == 2) { - pluralize = 'person'; - } - favText += 'by ' + favCount - + ' ' + pluralize + ' (including you)'; - } - } else /*if the user has not favorited the mission */ { - favText += 'by ' + favCount + ' ' + pluralize; - } - - return favText; - } -}; diff --git a/js/newworklist.js b/js/newworklist.js index f464c348..95a3fd17 100644 --- a/js/newworklist.js +++ b/js/newworklist.js @@ -21,7 +21,6 @@ var NewWorklist = { }); $('a[href^="./github/login"]').click(NewWorklist.loginClick); - $('.send_love').click(NewWorklist.sendLoveClick); /** * Initialize js objects used by worklist @@ -76,37 +75,6 @@ var NewWorklist = { } }, - sendLoveClick: function() { - var to_user = $(this).attr('user') ? $(this).attr('user') : 0; - Utils.modal('send-love', { - open: function(modal) { - $('input[name="to"]', modal).autocomplete({source: autocompleteUserSource}); - if (to_user) { - $('input[name="to"]', modal).val(to_user); - } - //$('input[name="to"]', modal).autocomplete({source: autocompleteUserSource}); - $('form', modal).submit(function() { - $.ajax({ - url: './user/sendLove/' + $('input[name="to"]', modal).val(), - data: { - love_message: $('textarea[name="love_message"]', modal).val() - }, - dataType: 'json', - type: "POST", - cache: false, - success: function(json) { - if (json.success) { - $(modal).modal('hide'); - } - } - }); - return false; - }); - } - }); - return false; - }, - initJobSearch: function() { $('#search-query input[type="text"]').keypress(function(event) { if ($.trim($(this).val()).length > 0 && event.keyCode == '13' && typeof jobs == 'undefined') { diff --git a/js/team.js b/js/team.js index 0d9e8341..0cc2300c 100644 --- a/js/team.js +++ b/js/team.js @@ -1,5 +1,5 @@ var current_letter = 'all'; -var current_sortkey = 'earnings30'; +var current_sortkey = 'jobs_count'; var current_order = false; var sfilter = '30'; // Default value for the filter var show_actives = "FALSE"; @@ -224,9 +224,6 @@ function AppendUserRow(json, odd) { row += ''+ json.joined + ''; row += '' + json.jobs_count + ''; row += '' + json.budget + ''; - row += '$' +addCommas(json.earnings.toFixed(2)) + ''; - row += '$' + addCommas(json.earnings30) + ''; - row += '(' + (Math.round((parseFloat(json.rewarder) / (parseFloat(json.earnings) + 0.000001)) * 100*100)/100)+ '%) $' + addCommas(json.rewarder) + ''; $('#table-userlist tbody').append(row); } @@ -243,11 +240,11 @@ function addCommas(nStr) { } function outputPagination(page, cPages) { - var previousLink = page > 1 - ? '
  • Previous
  • ' + var previousLink = page > 1 + ? '
  • Previous
  • ' : '
  • Previous
  • ', - nextLink = page < cPages - ? '
  • Next
  • ' + nextLink = page < cPages + ? '
  • Next
  • ' : '
  • Next
  • '; var pagination = previousLink; var fromPage = 1; diff --git a/js/userinfo.js b/js/userinfo.js index bf9c51ec..3b161b98 100644 --- a/js/userinfo.js +++ b/js/userinfo.js @@ -9,19 +9,6 @@ var UserInfo = { $('#manager').val(userInfo.manager); $('#referrer').val(userInfo.referred_by); - WLFavorites.init( "profileInfoFavorite",userInfo.user_id, userInfo.nickName ); - // setup the variables needed to call the getFavoriteText function - var favCount = $('.profileInfoFavorite span').attr('data-favorite-count'); - var isMyFav = false; - if ($('.profileInfoFavorite .favorite_user').hasClass('myfavorite')) { - isMyFav = true; - } - - // set the favText with the getFavoriteText function - var favText = WLFavorites.getFavoriteText(favCount, isMyFav, 'Trusted '); - - $('.profileInfoFavorite span').html(favText); - // master function to handle change in dropdowns $('select', '#admin').change(function() { var value = $(this).val(); @@ -99,7 +86,7 @@ var UserInfo = { // if (json } }); - + }); @@ -131,7 +118,7 @@ var UserInfo = { }); $('#ping-msg').autogrow(80, 150); - + $('#send-ping-btn').click(function() { $('#send-ping-btn').attr("disabled", "disabled"); var msg = $('#ping-msg').val(); @@ -140,9 +127,9 @@ var UserInfo = { var cc = $('#copy-me').is(':checked') ? 1 : 0; var data = { 'action': 'pingTask', - 'userid' : userInfo.user_id, - 'msg' : msg, - 'journal' : journal, + 'userid' : userInfo.user_id, + 'msg' : msg, + 'journal' : journal, 'cc' : cc }; $.ajax({ @@ -155,7 +142,7 @@ var UserInfo = { alert("Ping failed:" + json.error); } else { var success_msg = "

    Your message has been sent.

    "; - + Utils.emptyModal({ content: success_msg, buttons: [ @@ -169,14 +156,14 @@ var UserInfo = { } $('#ping-msg').val(""); $('#send-ping-btn').removeAttr("disabled"); - }, + }, error: function() { $('#send-ping-btn').removeAttr("disabled"); } }); return false; }); - + $('.reviewAddLink').click(UserInfo.reviewDialog); $('#give').click(function(){ @@ -263,7 +250,7 @@ var UserInfo = { }); return false; }); - + $('#budgetHistory').click(function(){ Budget.showBudgetHistory(1, userInfo.user_id); return false; @@ -271,19 +258,19 @@ var UserInfo = { $('#create_sandbox').click(function(){ var projects = ''; - + // get project ids that are newly checked - setup to allow adding // projects to sandbox that is already created, sandbox bash // script needs updating to support this $('#sandboxForm input[type=checkbox]:checked').not(':disabled').each(function() { if ($(this).prop('checked') && !$(this).prop('disabled')) { projects += $(this).next('.repo').val() + ','; - } + } }); - + if (projects != '') { // remove the last comma - projects = projects.slice(0, -1) + projects = projects.slice(0, -1) $.ajax({ type: "POST", url: './user/' + userInfo.user_id, @@ -305,13 +292,13 @@ var UserInfo = { } else { alert('You did not choose any projects to check out.'); } - + return false; }); $('#budget-source-combo-bonus').chosen({width: 'auto'}); var bonus_amount; - + $('#pay_bonus').click(function(e) { Utils.modal('paybonus', { open: function(modal) { @@ -394,7 +381,7 @@ var UserInfo = { clearStyle: true, collapsible: true, active: true, - create: function(event, ui) { + create: function(event, ui) { var workersIntervalId = setInterval(function() { if($("#runner-workers tr").length) { $('#runner-workers').paginate(limitPerPage, 500); @@ -408,8 +395,8 @@ var UserInfo = { } }, 2000); } - }); - + }); + if (! is_payer) { $('#ispaypalverified').prop('disabled', true); $('#isw9approved').prop('disabled', true); @@ -471,7 +458,6 @@ var UserInfo = { $('#profile-nav a[href="#' + tab + '"]').click(); } - $('#user-loves + a').click(UserInfo.displayAllLove); }, setW9Status: function(status, reason, fAfter) { @@ -492,7 +478,7 @@ var UserInfo = { appendPagination: function(page, cPages, table) { var cspan = '4' - var pagination = '' + + var pagination = '' + ''; if (page > 1) { pagination += '' + i + '  '; } } @@ -513,11 +499,11 @@ var UserInfo = { pagination += ''; $('.table-' + table).append(pagination); }, - + appendRow: function(json, table) { var pre = '', post = ''; var row; - + row = ''; row += '' + pre + json[0] + post + ''; // Date @@ -526,7 +512,7 @@ var UserInfo = { row += '' + pre + json[3] + post + ''; // Description row += ''; - + $('.table-' + table).append(row); }, @@ -536,16 +522,16 @@ var UserInfo = { type: 'GET', url: 'api.php', data: { - action: 'getBonusHistory', - uid: user_id, - rid: UserInfo.user_id, + action: 'getBonusHistory', + uid: user_id, + rid: UserInfo.user_id, page: page }, dataType: 'json', success: function(json) { var footer = 'No bonus history yet'; $('.bonus-history').find("tr:gt(0)").remove(); - + for (var i = 1; i < json.length; i++) { UserInfo.appendRow(json[i], 'bonus-history'); } @@ -606,24 +592,5 @@ var UserInfo = { } }); return false; - }, - - displayAllLove: function() { - var itemsPerPage = 5; - var nextPage = $('#user-loves cite').length / itemsPerPage + 1; - $.ajax({ - type: 'GET', - url: './user/loves/' + userInfo.nickName + '/' + nextPage + '/' + itemsPerPage, - dataType: 'json', - success: function(json) { - Utils.parseMustache('partials/user/loves', json, function(parsed) { - $('#user-loves').append(parsed); - if (json.page == json.pages) { - $('#user-loves + a').remove(); - } - }); - } - }); - return false; } }; diff --git a/lib/classes/User.php b/lib/classes/User.php index 599c3da1..1979bd33 100644 --- a/lib/classes/User.php +++ b/lib/classes/User.php @@ -1958,21 +1958,15 @@ public static function login($user, $redirect_url = './') { public function completedJobsWithStats() { $sql = " - SELECT w.id, w.summary, f.cost, + SELECT w.id, w.summary, DATEDIFF ((SELECT MAX(change_date) FROM " .STATUS_LOG. " WHERE `status` = 'Done' AND `worklist_id` = w.id), b.date) days FROM " . WORKLIST . " w LEFT JOIN " . FEES . " b ON b.worklist_id = w.id - LEFT JOIN ( - SELECT SUM(amount) cost, worklist_id - FROM " . FEES . " - WHERE withdrawn = 0 - GROUP BY worklist_id - ) f ON f.worklist_id = w.id WHERE - b.user_id = " . $this->getId() . " AND + b.user_id = " . $this->getId() . " AND (NOT b.`withdrawn`) AND w.`status` = 'Done' - GROUP BY w.`id` + GROUP BY w.`id`, b.`date` ORDER BY w.`id` DESC LIMIT 5"; diff --git a/views/Job.php b/views/Job.php index 880ed00f..aaa64a46 100644 --- a/views/Job.php +++ b/views/Job.php @@ -8,7 +8,6 @@ class JobView extends View { public $stylesheets = array( 'css/legacy/workitem.css', - 'css/favorites.css', 'css/entries.css', 'css/job.css' ); @@ -25,7 +24,6 @@ class JobView extends View { 'js/datepicker.js', 'js/timepicker.js', 'js/entries.js', - 'js/favorites.js', 'js/github.js', 'js/job.js' ); @@ -101,11 +99,11 @@ public function canChangeStatus() { $user = $this->user; $is_runner = $this->currentUser['is_runner']; return $this->currentUser['id'] && ( - ( !$this->workitem->getIsRelRunner() - || ($user->getIs_admin() == 1 && $is_runner) + ( !$this->workitem->getIsRelRunner() + || ($user->getIs_admin() == 1 && $is_runner) || ($worklist['mechanic_id'] == $this->currentUser['id']) && $worklist['status'] != 'Done' - ) + ) || $workitem->getIsRelRunner() || ($worklist['creator_id']== $this->currentUser['user_id'] && $worklist['status'] != 'Done') ); @@ -127,7 +125,7 @@ public function editableStatusSelect() { && $worklist['status'] != 'Done') { //mechanics $statusList = $statusListMechanic; - } else if ($workitem->getIsRelRunner() || ($user->getIs_admin() == 1 && $is_runner)) { + } else if ($workitem->getIsRelRunner() || ($user->getIs_admin() == 1 && $is_runner)) { //runners and admins $statusList = $statusListRunner; @@ -171,7 +169,7 @@ public function nonEditableRunnerBox() { $worklist = $this->worklist; $ret = ''; if ($worklist['runner_nickname'] != 'Not funded' && $worklist['runner_nickname'] != '') { - $ret .= + $ret .= '' . 'Designer:' . '' . $worklist['runner_nickname'] . ''; @@ -197,10 +195,10 @@ public function mechanicBox() { $mech = 'Developer:Not assigned'; } else { $tooltip = isset($_SESSION['userid']) ? "Ping Developer" : "Log in to Ping Developer"; - $mech = + $mech = '' . 'Developer:' . - '' . + '' . '' . $mech . ''; } return $mech; @@ -213,9 +211,9 @@ public function canEditSummary() { $is_runner = $this->currentUser['is_runner']; return ( - (($workitem->getIsRelRunner() || ($user->getIs_admin() == 1 && $is_runner)) && $worklist['status']!='Done') + (($workitem->getIsRelRunner() || ($user->getIs_admin() == 1 && $is_runner)) && $worklist['status']!='Done') || ( - $worklist['creator_id'] == $this->currentUser['id'] + $worklist['creator_id'] == $this->currentUser['id'] && ($worklist['status']=='Suggestion') && is_null($worklist['runner_id']) ) ); @@ -248,7 +246,7 @@ public function statusInfo() { $ret .= ''; } $ret .= ''; - } else { + } else { $ret .= $worklist['status'] . ' '; } return $ret; @@ -278,7 +276,7 @@ public function canSeeBudgetArea() { $worklist = $this->worklist; $user = $this->user; return ( - $user->isRunnerOfWorkitem($workitem) + $user->isRunnerOfWorkitem($workitem) || $_SESSION['userid'] == $worklist['budget_giver_id'] || strpos(BUDGET_AUTHORIZED_USERS, "," . $_SESSION['userid'] . ",") !== false ); @@ -323,7 +321,7 @@ public function canViewDiff() { $is_project_founder = $this->read('is_project_founder'); return ( ($worklist['status'] == 'QA Ready' || $worklist['status'] == 'Review') - && $worklist['sandbox'] != 'N/A' + && $worklist['sandbox'] != 'N/A' || ($worklist['status'] == 'In Progress' && ($user->isRunnerOfWorkitem($workitem) || $is_project_founder || $user->getId() == $worklist['mechanic_id'])) ); } @@ -332,7 +330,7 @@ public function canEditProject() { $is_project_runner = $this->read('is_project_runner'); $worklist = $this->worklist; return ( - ($is_project_runner || $worklist['creator_id'] == $this->currentUser['id'] || ($this->currentUser['is_admin'] && $this->currentUser['is_runner'])) + ($is_project_runner || $worklist['creator_id'] == $this->currentUser['id'] || ($this->currentUser['is_admin'] && $this->currentUser['is_runner'])) && ($worklist['status'] != 'Done') ); } @@ -362,7 +360,7 @@ public function comments() { } else { return array_reverse($this->read('comments'), true); } - + } public function isDescOrder() { @@ -390,12 +388,12 @@ public function canReview() { && $this->read('userHasCodeReviewRights') ) && ( - $worklist['status'] == 'Review' + $worklist['status'] == 'Review' && (! $workitem->getCRCompleted()) && ( - (! $workitem->getCRStarted()) - || $this->currentUser['id'] == $workitem->getCReviewerId() - || $workitem->getIsRelRunner() + (! $workitem->getCRStarted()) + || $this->currentUser['id'] == $workitem->getCReviewerId() + || $workitem->getIsRelRunner() || ($user->getIs_admin() == 1 && $is_runner) ) ) @@ -406,11 +404,11 @@ public function canEndReview() { $workitem = $this->workitem; $user = $this->user; $is_runner = $this->currentUser['is_runner']; - return + return $workitem->getCRStarted() && ( - $this->currentUser['id'] == $workitem->getCReviewerId() - || $workitem->getIsRelRunner() + $this->currentUser['id'] == $workitem->getCReviewerId() + || $workitem->getIsRelRunner() || ($user->getIs_admin() == 1 && $is_runner) ) && !$workitem->getCRCompleted(); @@ -427,7 +425,7 @@ public function codeReviewFeeAmount() { public function canBid() { $worklist = $this->worklist; - return $worklist['status'] == 'Bidding' + return $worklist['status'] == 'Bidding' || ($worklist['status'] == 'Suggestion' && $worklist['creator_id'] == $this->currentUser['id']); } @@ -441,9 +439,9 @@ public function canAcceptBids() { $user = $this->user; $is_runner = $this->currentUser['is_runner']; return ( - (!empty($bids)) - && ($workitem->getIsRelRunner() || ($user->getIs_admin() == 1 && $is_runner) || $this->currentUser['id'] == $workitem->getRunnerId()) - && count($bids) >1 + (!empty($bids)) + && ($workitem->getIsRelRunner() || ($user->getIs_admin() == 1 && $is_runner) || $this->currentUser['id'] == $workitem->getRunnerId()) + && count($bids) >1 && !$workitem->hasAcceptedBids() && ((($workitem->getStatus()) == "Bidding")) ); @@ -498,7 +496,7 @@ public function bidsList() { $notes = addcslashes(preg_replace("/\r?\n/", "
    ", $bid['notes']),"\\\'\"&\n\r<>"); if ($canSeeBid) { - $ret .= + $ret .= ""; } - $ret .= + $ret .= '' . ( - $canSeeBid + $canSeeBid ? '' . $bid['nickname'] . '' : $bid['nickname'] ) @@ -541,15 +539,15 @@ function feesList() { $workitem = $this->workitem; $worklist = $this->worklist; $user = $this->user; - + $feeTotal = 0; $ret = ''; - + foreach($fees as $fee) { $paid = (bool) $fee['paid']; $feeTotal += (float) $fee['amount']; $date = explode("/", $fee['date']); - $ret .= + $ret .= '' . '