CVS edit link for yazna

I wan to contribute with Infowordpress module, this module allows view posts and blogs from Wordpress Mu inside Drupal. Infowordpress provides integration with wordpress's XMLRPC web service. Requieres infoxmlrpc plugin (http://wpmudev.org/project/infomed-xml-rpc-methods) for Wp Mu.

Comments

dave reid’s picture

Please attach the module's code as a follow-up here.

yazna’s picture

Component: Miscellaneous » Code
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new25.19 KB
new51.15 KB

Infowordpress module depends of infoutilities

avpaderno’s picture

Component: Code » Miscellaneous
Status: Needs review » Needs work

A module normally uses hook_menu() to define menu callbacks that are present in its code; this module uses as callback functions that are defined in another module. It would be better to move on Infoutilities the menu callbacks that are relative to that module.

yazna’s picture

Status: Needs work » Fixed
StatusFileSize
new20.67 KB
new8.19 KB
new20.67 KB
yazna’s picture

StatusFileSize
new8.19 KB
new20.67 KB
avpaderno’s picture

Status: Fixed » Needs review

@yazna: The status can be changed to fixed only by AjK, which will approve your application.

avpaderno’s picture

Status: Needs review » Needs work
  1. function infoutilities_theme() {
      return array(
        'pagerarray' => array(
          'arguments' => array('tags' => NULL, 'limit' => 10, 'element' => NULL, 'parameters' => array(), 'quantity' => 5),
          'function' => 'theme_pagerarray',
        ),
        // ...
      );
    }
    

    If the name of the theme function is the one that Drupal would use, it's perfectly useless to define it. Each function a module define should respect its namespace (if the module is nodewords.module, then its functions must have a name starting with "nodewords_".

  2. /**
     * Funcion auxiliar para eliminar los acentos del texto que se pasa al buscador 
     *
     * @param $s
     *   texto al que se le van a quitar los acentos, Ò
     * @return
     *   texto sin acentos ni Ò
     */
    

    Comments should be in English.

  3. The installation file can be removed, when the un/installation functions don't do anything.
  4. function infowordpress_decryptData($value, $key) {
      
      $crypttext = $value;
      $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
      $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
      $decrypttext = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($crypttext), MCRYPT_MODE_ECB, $iv));
      
      return trim($decrypttext);
    }
    

    trim() is called twice for the same string.

  5.   if (isset($form_state['storage'])) {
        $defaults['type'] = $form_state['storage']['stored_type'];
        $defaults['title'] = $form_state['storage']['stored_title'];
        $defaults['setid'] = $form_state['storage']['stored_setid'];
        $defaults['blogname'] = $form_state['storage']['stored_blogname'];
        $defaults['display'] = $form_state['storage']['stored_display'];
        $defaults['display_others'] = $form_state['storage']['stored_display_others'];
      }
    

    It would be better to change it to use normal variables, and change the code to something similar to

      if (isset($form_state['storage'])) {
        $type = $form_state['storage']['stored_type'];
        $title = $form_state['storage']['stored_title'];
        $setid = $form_state['storage']['stored_setid'];
        $blogname = $form_state['storage']['stored_blogname'];
        $display = $form_state['storage']['stored_display'];
        $display_others = $form_state['storage']['stored_display_others'];
      }
    
  6.       $form['mostrar'] = array(
            '#type' => 'fieldset',
            '#title' => t('View in block'),
          );
    

    "mostrar" is another not English word.

  7.   $ws_url = check_url($result->url) . (($form_state['values']['blogname'] == '') ? 'xmlrpc.php' : $form_state['values']['blogname'] .'/xmlrpc.php');
      if (!$fp = @fopen($ws_url, "r")) {
        form_set_error('url', t('Sorry, that is not a valid URL for Wordpress Mu.'));
      }
    

    The code works only in the case URLs are allowed in calls to fopen(); this is not always the case, and some web server providers don't allow that. The code must function without to take assumptions on the PHP configuration, if not the ones that Drupal already does.

  8.   $result = db_fetch_object(db_query("SELECT * FROM {infowordpress_settings} WHERE setid=%d", $form_state['values']['setid']));
    

    It would be better if the settings of the module are saved using variable_set(), and obtained with variable_get(). Using those functions would remove the need of an extra SQL query; Drupal variables are also cached, and that makes the system faster.

  9.     if (!is_numeric($form_state['values']['numentry'])) {
          $mensaje = $type==1?t('You must insert a number of Post Id.'):t('You must insert a number for the maximum number of posts.');
          form_set_error('numentry', $mensaje);
        }
    

    The code must place spaces around the operators; the code should be rewritten as

        if (!is_numeric($form_state['values']['numentry'])) {
          $mensaje = $type == 1 ? t('You must insert a number of Post Id.'):t('You must insert a number for the maximum number of posts.');
          form_set_error('numentry', $mensaje);
        }
    

    Variables should be named using English words. The code you are developing must be understandable also from other people.

  10. function infowordpress_block_edit_submit($form, &$form_state) {
      $clicked = $form_state['clicked_button']['#value'];
      
      switch ($clicked) {
      // ...
    }
    

    Submit functions should not depend on values like $form_state['clicked_button']['#value']; it's possible to assign a submit function to each button present in a form, and that should be the way to assign submit functions, when the submit buttons are more than one.

  11.       $form_state['rebuild'] = TRUE;
          $form_state['storage'] = array(
            // ...
          );
    

    It's not necessary to set $form_state['rebuild'], when $form_state['storage'] is set.

  12. function infowordpress_admin_delete($iwpid = 0) {
      return drupal_get_form('infowordpress_confirm_delete_form', $iwpid);
    }
    

    Rather than using infowordpress_admin_delete(), it would be better to just define infowordpress_confirm_delete_form() as menu callback (or as argument for the menu callback); different menus can use the same callback function.

yazna’s picture

Status: Needs work » Needs review
StatusFileSize
new7.7 KB
new20.37 KB
avpaderno’s picture

Status: Needs review » Needs work

Some of the things I reported before are still valid (especially for infoutilities.module).
I would also check the encoding for infoutilities.module because some characters are only visible setting the encoding to UTF-8; doing that, then, it's not possible to see the accented vowels you use in another part of the code.

I will check what encoding is suggested to use for the files uploaded on CVS, and I will report here.

avpaderno’s picture

Global Variables
If you need to define global variables, their name should start with a single underscore followed by the module/theme name and another underscore.

One of the modules uses global variables, but they are not named following those rules.
An alternative of using global variables is using static variables inside a function that is called to set, or get the value of those variables.

yazna’s picture

Status: Needs work » Needs review
StatusFileSize
new7.11 KB
new19.53 KB
yazna’s picture

StatusFileSize
new7.11 KB

Previous infoutilities module has errors, rewiev this attached here

yazna’s picture

StatusFileSize
new19.76 KB

I made some changes at infowordpress module

avpaderno’s picture

Issue tags: +Module review
avpaderno’s picture

Status: Needs review » Fixed
Issue tags: +Drupal 6.x

Status: Fixed » Closed (fixed)
Issue tags: -Drupal 6.x, -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
Issue tags: -Drupal 6.x

Status: Fixed » Closed (fixed)

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