From e97b48591d992fd52263ca3ae5b55103faa8e976 Mon Sep 17 00:00:00 2001 From: Lucas Crisman Date: Thu, 15 Feb 2018 16:15:27 -0300 Subject: [PATCH 1/4] remove Total earnings, 30 day earnings and % bonus from Team Members page --- api.php | 18 +++--------------- js/team.js | 13 +++++-------- views/mustache/team.mustache | 5 +---- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/api.php b/api.php index 6769ca87..5f5761fe 100644 --- a/api.php +++ b/api.php @@ -820,7 +820,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 +861,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/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/views/mustache/team.mustache b/views/mustache/team.mustache index 447e4a69..506f86a1 100644 --- a/views/mustache/team.mustache +++ b/views/mustache/team.mustache @@ -33,9 +33,6 @@ Age
    Jobs
    Budget
    - Total Earnings
    - 30 Day Earnings
    - (%) Bonus $
    @@ -71,4 +68,4 @@
  • Y
  • Z
  • -
      \ No newline at end of file +
        From dcabc8e7fa924bb5063d073f0520725cd6adb3e8 Mon Sep 17 00:00:00 2001 From: Lucas Crisman Date: Thu, 15 Feb 2018 16:19:43 -0300 Subject: [PATCH 2/4] User profile: hide earnings information --- lib/classes/User.php | 12 +++--------- views/User.php | 27 +++++++++------------------ views/mustache/user.mustache | 25 ++++++++----------------- 3 files changed, 20 insertions(+), 44 deletions(-) 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/User.php b/views/User.php index c0d4681c..83b7f329 100644 --- a/views/User.php +++ b/views/User.php @@ -153,15 +153,6 @@ public function timezone() { return $timezoneTable[$this->profileUser->getTimezone()]; } - public function totalEarnings() { - setlocale(LC_MONETARY,'en_US'); - return preg_replace('/\.[0-9]{2,}$/','',money_format('%n', $this->profileUser->totalEarnings())); - } - - public function latestEarnings() { - return preg_replace('/\.[0-9]{2,}$/','',money_format('%n', $this->profileUser->latestEarnings(30))); - } - public function ownProfile() { return $this->reqUserId > 0 && $this->profileUser->getId() == $_SESSION['userid']; } @@ -187,7 +178,7 @@ public function reviewsList() { $feeRangeTitle ='Number of jobs the reviewer has worked on'; $feeText = "From a user involved in " .$feeRange . " Worklist jobs ..."; } - $res .= + $res .= '
        ' . $feeText . "
        " . $review['review'] . "
        " . '
        ' ; @@ -199,8 +190,8 @@ public function reviewsList() { public function disableGiveBudget() { $reqUser = $this->read('reqUser'); $reqUserId = $this->read('reqUserId'); - return - (!$reqUser->isRunner() || $reqUserId == $this->profileUser->getId()) + return + (!$reqUser->isRunner() || $reqUserId == $this->profileUser->getId()) && strpos(BUDGET_AUTHORIZED_USERS, "," . $reqUserId . ",") === false; } @@ -252,7 +243,7 @@ public function userIsInactive() { } public function userIsActive() { - return $this->profileUser->getIs_active() == 1; + return $this->profileUser->getIs_active() == 1; } public function userIsSecured() { @@ -266,11 +257,11 @@ public function lastSeen() { public function projectsList() { $ret = ''; foreach ($this->projects as $project) { - $ret .= + $ret .= '
        ' . 'has_sandbox) && $this->profileUser->isProjectCheckedOut($project['id'])) { - $ret .= 'checked="checked" disabled="disabled" '; + if (($this->has_sandbox) && $this->profileUser->isProjectCheckedOut($project['id'])) { + $ret .= 'checked="checked" disabled="disabled" '; } $ret .= 'type="checkbox" id="' . $project['id'] . '" />'; $ret .= '' . $project['name'] . '
        '; @@ -282,7 +273,7 @@ public function runnerWorkers() { $ret = ''; if ($runnerWorkers = $this->profileUser->developersForDesigner()) { foreach($runnerWorkers as $runnerWorker) { - $ret .= + $ret .= '' . '' . $runnerWorker['nickname'] . '' . '' . $runnerWorker['totalJobCount'] . '' . @@ -297,7 +288,7 @@ public function runnerProjects() { $ret = ''; if ($runnerProjects = $this->profileUser->projectsForRunner()) { foreach($runnerProjects as $runnerProject) { + - $ret .= + $ret .= '' . '' .$runnerProject['name'] . '' . '' . $runnerProject['totalJobCount'] . '' . diff --git a/views/mustache/user.mustache b/views/mustache/user.mustache index 9f7bb260..6e07aa15 100644 --- a/views/mustache/user.mustache +++ b/views/mustache/user.mustache @@ -25,7 +25,7 @@
         
        -
        +
        {{& profileInfoFavorite}}
        @@ -33,11 +33,11 @@

        Location:
        {{#profileUser.getCity}} - {{profileUser.getCity}} {{/profileUser.getCity}} {{#countryCodeUrl}} - {{profileUser.getCountry}} {{/countryCodeUrl}}

        @@ -57,13 +57,6 @@ {{/jobs}} {{^jobs}}0{{/jobs}}

        -

        - Total earned: ${{totalEarnings}} -

        -

        - Last 30 days: - ${{latestEarnings}} -

        @@ -150,7 +143,7 @@

        - {{/ownProfile}}{{/reqUserId}} + {{/ownProfile}}{{/reqUserId}}

        Active jobs

        @@ -179,7 +172,6 @@ Job ID & Summary - Cost Time @@ -187,7 +179,6 @@ {{#completedJobs}} #{{id}} {{summary}} - {{#cost}}{{cost}}{{/cost}}{{^cost}}0.00{{/cost}} {{#days}}{{days}} days{{/days}}{{^days}}1 day{{/days}} {{/completedJobs}} @@ -197,7 +188,7 @@
        @@ -339,7 +330,7 @@
        -
        +

        Who has worked for Designer

        @@ -357,7 +348,7 @@
        -

        Projects worked on by Designer

        +

        Projects worked on by Designer

        @@ -371,7 +362,7 @@ {{& runnerProjects}}
        -
        +
        From 315ca09aa52e9489a3acf64396b220a761816682 Mon Sep 17 00:00:00 2001 From: Lucas Crisman Date: Thu, 15 Feb 2018 16:21:24 -0300 Subject: [PATCH 3/4] trustedBy/favorites feature gone --- api.php | 55 ---------------- css/favorites.css | 72 --------------------- css/userinfo.css | 36 ++--------- js/favorites.js | 118 ----------------------------------- js/userinfo.js | 69 +++++++++----------- views/Job.php | 86 +++++++++++++------------ views/User.php | 2 - views/mustache/user.mustache | 10 ++- 8 files changed, 79 insertions(+), 369 deletions(-) delete mode 100644 css/favorites.css delete mode 100644 js/favorites.js diff --git a/api.php b/api.php index 5f5761fe..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(); 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..2c6bbaf9 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, @@ -477,14 +477,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 +511,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; @@ -736,4 +710,4 @@ form#roles ul li { 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/userinfo.js b/js/userinfo.js index bf9c51ec..f4b5dafe 100644 --- a/js/userinfo.js +++ b/js/userinfo.js @@ -7,20 +7,7 @@ var UserInfo = { // set the current values $('#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); + $('#referrer').val(userInfo.referred_by); // master function to handle change in dropdowns $('select', '#admin').change(function() { @@ -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); @@ -492,7 +479,7 @@ var UserInfo = { appendPagination: function(page, cPages, table) { var cspan = '4' - var pagination = '' + + var pagination = '' + ''; if (page > 1) { pagination += '' + i + '  '; } } @@ -513,11 +500,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 +513,7 @@ var UserInfo = { row += '' + pre + json[3] + post + ''; // Description row += ''; - + $('.table-' + table).append(row); }, @@ -536,16 +523,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'); } 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 .= '' . '