CVS edit link for matuck

I have been developing for about 10 years. I have been developing php applications and websites for about 5 years. There are a few projects I am wanting to contribute.

The first project I am looking at is Ranks. Ranks is a hierarchy ranks system. The system is designed so that when you get promoted or demoted in rank, your Drupal role will change. The idea is ease of administration for large clan/guild websites where your rank controls your permission level. This also allows someone to check the date of there last promotion and well as some additional administrative features to help track when someone is eligible for a new rank.

The second module is ts3viewer. This module allows you to view your teamspeak server on your website. It has a complete list of channels and the current user signed in. This also creates a link to connect to your teamspeak server.

Comments

matuck’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new51.11 KB

adding attachment of ranks module.

matuck’s picture

Status: Active » Needs review

reset status i set wrong

matuck’s picture

StatusFileSize
new62.29 KB
new21.08 KB
new29.22 KB
new54.76 KB
new9.87 KB

Added screenshots of module.

avpaderno’s picture

Hello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review the code, pointing out what it needs to be changed.

What is the difference between ranks, and roles? Why would a site use ranks when Drupal already uses roles?

avpaderno’s picture

Issue tags: +Module review
matuck’s picture

Rank is logical. the ranks system controls the roles you have.
ranks are more of a logical structure one role could be associated with multiple ranks. or one rank could be associated with multiple roles.

matuck’s picture

How long does it take for someone to review

michelle’s picture

Given that Kiam is pretty much the only one doing it and the queue is long... It takes a while. I tried helping out but I suck at code reviews. :( If you're any good at doing code reviews, you could always help out and move things along faster. :)

Michelle

matuck’s picture

StatusFileSize
new54.96 KB

adding new attachment the only change in this is version line removed from .info file.

matuck’s picture

StatusFileSize
new55.13 KB

I guess I'm sorta self reviewing my code. after reading some of the comments in the other cvs requests I have went back and found a few more issues. A few small coding standards issue created by a find/replace. And missing a few hook comments attaching a new version of code

matuck’s picture

Any update yet on a reviewer

matuck’s picture

Any update here it has been a few weeks.

matuck’s picture

any update yet it has been nearly 2 months since my initial request and no review yet.

michelle’s picture

I know it's not much consolation but this is most definitely a case of "It's not you, it's us". See #703116: Our CVS account application requirements are obtuse and discourage contributions

Michelle

matuck’s picture

StatusFileSize
new55.82 KB

Adding new version. I have added alot of commenting to the code. Rewrote several db_query() calls.
The sql inside each was incorrect and not up to the drupal api.

Scyther’s picture

Status: Needs review » Needs work

1.

$result = db_query(sprintf('SELECT rr.roster_id, rr.uid, UNIX_TIMESTAMP(rr.date)  FROM {ranks_roster} rr WHERE rr.rank_id=\'%s\' ORDER BY rr.date', $rank_id));

// Why not only

$result = db_query("SELECT rr.roster_id, rr.uid, UNIX_TIMESTAMP(rr.date)  FROM {ranks_roster} rr WHERE rr.rank_id='%s' ORDER BY rr.date", $rank_id);

2. This is wrong! Don't put variables in t like this.

  drupal_set_message(t(ranks_getUserName($form_values['values']['adduser']) .' was added.'));

  // use like this instead
  drupal_set_message(t('@user was added.', array('@user' => ranks_getUserName($form_values['values']['adduser']))));

3. Use check_plain() on variables that is user inputs.

$output .= "<table class=\"indranks\"><tr><td width=\"33.3%\">". ranks_getUserName($cur_user['uid']) ."</td><td width=\"33.3%\">$cur_user[date]</td><td width=\"33.3%\" align=\"right\">$thisrank[shortname]</td></tr></table>";

4. Use http://drupal.org/project/coder and check your code. I have not done that, but by only looking at your code there is some faults if you will following http://drupal.org/coding-standards

matuck’s picture

StatusFileSize
new55.82 KB

1. I missed one. Had already changed the others. That has been corrected.
2. MIssed that one. but has been corrected.
3. I believe this is fixed; however, I have a question.

$form['name'] = array(
      '#type' => 'textfield',
      '#title' => t('Rank Name'),
      '#size' => 30,
      '#default_value' => $name,
      '#maxlength' => 64,
      '#description' => t('The full name of the rank')
  );

should #default_value be check_plain($name); Or does form rendering take care of that?
4. I have ran through coder and fixed all errors/notice's it shown.

Thanks for the review.
Attached new version with fixes.

matuck’s picture

Status: Needs work » Needs review

reset status back to needs review

Scyther’s picture

Status: Needs review » Needs work

On your question, in your ex with a form "object" you don't need to use check_plain on #default_value.

example from http://drupal.org/node/28984

$form['bad'] = array(
'#type' => 'textfield',
'#default_value' => check_plain($u_supplied),  // bad: escaped twice
'#description' => t("Old data: !data", array('!data' => $u_supplied)), // XSS
);

$form['good'] = array(
'#type' => 'textfield',
'#default_value' => $u_supplied,
'#description' => t("Old data: @data", array('@data' => $u_supplied)),
);

- - - - -

1. Why use escape \ here, when you can use " " around the query and have ' ' inside?

$result = db_query('SELECT rr.roster_id, rr.uid, UNIX_TIMESTAMP(rr.date)  FROM {ranks_roster} rr WHERE rr.rank_id=\'%s\' ORDER BY rr.date', $rank_id);

// as this
$result = db_query("SELECT rr.roster_id, rr.uid, UNIX_TIMESTAMP(rr.date)  FROM {ranks_roster} rr WHERE rr.rank_id='%s' ORDER BY rr.date", $rank_id);

2. Why do you use " " sometimes and sometimes ' ' on SQL querys? Why not use " " all the time?

3. Another tips, not to use escape chars so much.

$output = "<div class=\"rankspageheader\">";

// do like this
$output = '<div class="rankspageheader">';

4. You might want to use theme('image', ...) here instead and on other places that you have img. See http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_image/6

$output .= "<div class=\"rankspageheaderimage\"><img src=\"" . ranks_imagepath('ranks.gif') . " \"></div>\n";

5. There is a theme('table', ...) for making tables, see http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_table/6

$output .= "<table class=\"indranks\"><tr><td>" . t('No one in this rank') . "</td></tr></table>";

6. Not secure!

db_query('DELETE FROM {ranks} WHERE rid = ' . $key);

// do like this
db_query("DELETE FROM {ranks} WHERE rid = %d", $key);

7. Why "rr", makes no seens.

db_query('SELECT rr.uid, rr.name  FROM {users} rr ORDER BY rr.name');

// Also, when only geting data from one table you can write like this. But what you did was not wrong, you were only very clear about it.
db_query('SELECT uid, name  FROM {users} ORDER BY name');

8. Why have a if and else, when you can change the if statment and remove the else.

  if ($users === FALSE) {
    //do nothing
  }
  else {

- - - - -

  • The points reported in this review are not in order of importance / relevance.
  • Most of the times I report the code that present an issue. In such cases, the same error can be present in other parts of the code; the fact I don't report the same issue more than once doesn't mean the same issue is not present in different places.
matuck’s picture

Status: Needs work » Needs review
StatusFileSize
new55.84 KB

1. is fixed.
2. Have no idea... Guess I should have standardize that
3. Removed most escaped characters.
4. Fixed. I actually like that looks much cleaner.
5. Fixed. and as a side affect makes code and display look much better
6. Fixed another missed query.
7. Fixed. copy paste error.
8. Fixed. I think i was gonna do something else there and then didn't.

Thanks again for your reviews.

Scyther’s picture

Status: Needs review » Needs work

Some tips.

1. Why do you add this to almost all menu items? It's the same as the default so you could save some lines of code.

  'type' => MENU_NORMAL_ITEM,

2. Indenting is bad on some places, it gets easier to read if you do it little better.

  // ex.
  $form['sorting'] = array('#type' => 'hidden',
              '#value' => $sorting);

- - -
Errors

1.

  theme_image(ranks_imagepath('ranks.gif'))
  // should be, so it can be overrided
  theme('image', ranks_imagepath('ranks.gif'))

2.

  drupal_set_message(t('Delete user ') . check_plain(ranks_getUserName($uid)));
 
  // alternative, when using @ the variable will automatic passed through check_plain()
  drupal_set_message(t('Delete user @user', array('@user' => ranks_getUserName($uid)));

3. Use quotes around a string literal array index, this is not only a style issue, but a known performance problem

    $output .= '<div class="ranksheader"><div class="ranksheadername">' . $thisrank[name] . '</div>';
matuck’s picture

Status: Needs work » Needs review
StatusFileSize
new55.79 KB

Tips:
1. Fixed
2. I think I got all of these

Errors:
1. All fixed
2. Fixed
3. Can't believe missed that one but Fixed.

Thanks for review again.

michelle’s picture

Since matuck has shown great patience and tenacity through this process, I went ahead and approved the account. If Scyther wants to keep reviewing and get all the kinks out, that would be great. In the mean time, matuck now has access to set up an account and get the code into CVS so he can make use of versioning and the issue queue. I'll leave this at needs review so I don't prematurely stop the great reviewing that's going on here but you folks can marked this as "fixed" whenever you're ready.

Michelle

matuck’s picture

Thanks Michelle.

I will continue to check back here for a review. I value the input and it helps me become a better drupal coder.

Scyther’s picture

I can give review on the module later on the project page. If you are intressted in a co-maintainer matuck, send me a message through my contact form.

avpaderno’s picture

Status: Needs review » Fixed

I am changing the status as the CVS account has been already approved.

Status: Fixed » Closed (fixed)
Issue tags: -Module review

Automatically closed -- issue fixed for 2 weeks with no activity.

avpaderno’s picture

Component: Miscellaneous » new project application
Issue summary: View changes
Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.