Our customers – who have a web site based on Drupal – have a lot of questions regarding where to display ads. Therefore, I’ve been assigned to create a module which displays BannerConnect ads, and to maintain it. Obviously, if more users start using our module, the amount of websites we have will increase.
The first module that I want to contribute is called bannerconnect_adspace. This module offers its users the display of 6 different ad sizes. I’ve created a block for each ad, and the user will be able to use these blocks to see where he’d like to have his ad. In order for this to work the user needs a section ID, which he’ll obtain after signing up as one of BannerConnect’s publishers. Without a section ID demo ads will be shown. Once the user is using the demo, an ad message will appear above the ad.
Please provide me with an account to your web site, so I can make this will work the way it’s supposed to.
with kind regards,
Niki Mathijsen
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | bannerconnect_adspace.zip | 5.83 KB | tcniki |
| #7 | bannerconnect_adspace.zip | 5.88 KB | tcniki |
| #4 | bannerconnect_adspace.zip | 4.79 KB | tcniki |
| #5 | bannerconnect_adspace.zip | 4.46 KB | tcniki |
| #2 | bannerconnect_adspace.zip | 4.61 KB | tcniki |
Comments
Comment #1
avpadernoPlease provide the code of the module here, so it can be reviewed.
Comment #2
tcniki commentedThis is the BannerConnect module.
More information about TechConnect or BannerConnect could be found at:
http://www.techconnect.nl/
http://www.bannerconnect.net/
Comment #3
avpadernoThe IF-statement can be simply wrote
Also,
if ($key_exist == 1) {is equivalent ofif ($key_exist), if you just need to check for 1 against 0 (orTRUEagainstFALSE).To notice that
array_key_exists()returnsTRUE, orFALSE.The indentation character should not be the tab, but two spaces.
The loop can be simply written as
Check also the coding standards for how to write Drupal compliant code.
The code can be simply written as
The code should not try to access a variable, or an object property without to verify if it is set.
The code can probably be simplified in
If the function is used in just a place, and it is not supposed to be called from third-party modules, then it can be removed.
That is the default value; there is no need to explicitly set it.
What is the purpose of that comment?
It's not a PHP file; the
<?phpneeds to be removed.There is no need to set the value of Drupal variables; if the variables are not set,
variable_get()will return the second parameter.The uninstall queries can be replaced by
In this way, you don't need to add new queries when you add more Drupal variables.
Comment #4
tcniki commentedThanks for the very quick review. I changed almost every comment you made.
I found a little error in your code. At point 4, you write:
but it has to be
Since there is no for loop with variable $i, $adspaces remains empty.
There is 1 point I do not understand. At point 10 you write that there is no need to set the value of Drupal variables. However, if I delete the install query's I have to check them every time I want to store a variable.
Because if those variables don't exist in the database I have to run an insert statements instead of an update statement. This would result in 2 query for storing the data instead of 1. The first would be a check if the records exist in the table, and the second then would be a insert or an update statement. EDIT -> solved
See next comment for latest module.
Comment #5
tcniki commentedI had to edit the module. After some readwork I understand what you mean with variable_get. I now replaced almost every query (only the uninstall hook uses db_query) with variable_get and variable_set.
Comment #6
avpadernobannerconnect_adspace_block()you keep to set$enabledto 1 (I would rather set it to TRUE, so it would be clearer the purpose of the variable - as the code is, it seems the variable counts the number of items enabled), and then check if that variable is 1 (which is always true, because you set it to 1). The code must be changed. When$opis "view", you are supposed to return the blocks you are listed when$opwas "list"; as Drupal will not pass to your hook a value for$deltathat you didn't return, that code is useless.There is duplicated code.
strlen($section_id)should bedrupal_strlen($section_id).All your functions must have a name starting with
bannerconnect, and the same is true also for the Drupal variables used by your code.Comment #7
tcniki commented2. I think you misunderstood my code, so I changed it. The variable former known as $enabled was used to check if the user enabled the specific ad. If the users didn't then a empty block was returned. I changed it know so other people would recognise the use of it.
3. I typed the indentation manually, every where 2 spaces. Can you tell me how to check if there are correct.
Comment #8
tcniki commentedSince I cannot edit the attachments or the status, here's a new submit.
I'm using eclipse and finaly found out how I could see the tabs. I removed the last remaining, so no tabs are there anymore. The line endings are also now in UNIX style (/n instead of /r/n)
Comment #9
avpadernoBefore to commit the code in CVS, remember to remove the bc_adspace_main_settings.inc file.
Also, the following code can be optimized:
Rather than checking for
$key_existon every CASE-branch, it would be better to check the value of that variable before the SWITCH-statement.Thank you for your contribution! I am going to update your account.
These are some recommended readings to help with excellent maintainership:
You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
I thank all the dedicated reviewers as well.
Comment #11
avpaderno