CVS edit link for bob_hirnlego

I work as a developer for Radio Radicale, an Italian radio website.
They asked for a solution for maintaining a network of sites under D6 with shared resources (users, nodes and taxonomies) and my team developed a module called Hydra.
Hydra is similar to Domain Access in the main purpose, but approaches the matter in a different way: while Domain Access derives a new site from a master and then tries to give it some independence, on the contrary Hydra creates an independent site and then adds it to the network.
Technically Domain Access uses a single Drupal site, Hydra creates a site for each domain.
This way, every Hydra site is totally independent when it comes to files, modules and themes.
This also means more order and tidiness when working on a lot of sites with different administrators.
Each new site is cloned from a "template" site which must be properly arranged, and the creation is done in one click.
There's a lot more to it, but I'd like to make clear that we developed Hydra when Domain Access for D6 was young and lacking the features we needed. Besides, we noted that Domain Access was too complex to setup and use for our needs, so we decided to write our solution. When we compared them lately, though, we came to the conclusion that while Domain Access is more suitable for a group of affiliated sites that share more than the contents, Hydra is best suggested to those who want to focus on sites identity and autonomy.
CommentFileSizeAuthor
#7 hydra.zip39.66 KBbob_hirnlego
#5 hydra.zip40.64 KBbob_hirnlego
#1 hydra.zip46.54 KBbob_hirnlego

Comments

bob_hirnlego’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new46.54 KB
avpaderno’s picture

Status: Needs review » Needs work
  1. // $Id: $
    

    The CVS ID tag should be $Id$.

  2.     drupal_set_message(t("Warning: note that your account is limited because it's not yet been convalidated.<br>Please recheck your email inbox and spam folder.<br>If you didn't received the email " . l("follow this link for a new request","toboggan/revalidate/{$user->uid}")) ,'error');
    

    Rather than concatenating a string, use a placeholder; concatenated string cannot be extracted for translation, and the string would not appear in the translation template.

  3. hook_init() is called only on not cached pages; depending on the case, this could cause problems.
  4.       die;
    

    Hook implementations should never call die().

  5.     if (drupal_strlen($object->name) > 20) {
          $name = drupal_substr($object->name, 0, 15) . '...';
        }
    

    Drupal has the function truncate_utf8().

  6.   global $hydra_master_name, $hydra_copy_tables, $user;
    

    Global variables used by the module should be named something like $_hydra_master_name.

  7. function hydra_get_db_tables($prefix) {  
      $tables = array();
      $result = db_query("SHOW TABLES LIKE '{$prefix}_%'");
      while ($table = db_fetch_array($result)) {
        $value = array_values($table);
        $name = str_replace("{$prefix}_", '', $value[0]);
        $tables[$name] = $name;
      }  
      return $tables;
    }
    

    Isn't SHOW TABLES specific for a database engine?

  8.   $hostname = hydra_get_current_hostname();
      $site = db_fetch_object(db_query("SELECT * FROM {hydra_sites} WHERE hostname = '%s' LIMIT 1", $hostname));
    

    For that, there is the function db_query_range().

  9.   watchdog('hydra join', "User {$account->name} joined {$site->fullname}");
    

    Use placeholders.

  10.   $nids = '('.join(',',$nids).')';
      // Prepare update values
      $set = "{$op} = {$value}";
      db_query("UPDATE {hydra_nodes} SET {$set} WHERE nid IN {$nids} AND sid = %d", $hydra_current_site->sid);
    }
    

    There is the function db_placeholders().

  11.   // We check the paths registered by setting.
      $pages = variable_get('hydra_disabled_user_db_rewrite', join("\n", $paths));
      $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($pages, '/')) .')$/';
      // Compare with the internal and path alias (if any).
      $page_match = preg_match($regexp, $_GET['q']);
      if (!$page_match && function_exists('drupal_get_path_alias')) {
        $path = drupal_get_path_alias($_GET['q']);
        if ($path != $_GET['q']) {
          $page_match = preg_match($regexp, $path);
        }
      }
      if ($page_match) {
        return TRUE;
      }
    

    There is the function drupal_match_path().

  12.   $default_settings = $_SERVER['DOCUMENT_ROOT'] . '/' . drupal_get_path('module', 'hydra') . '/misc/settings.php.template';
      $settings_file = "{$_SERVER['DOCUMENT_ROOT']}/sites/{$values['name']}/settings.php";
    

    base_path() is normally used in such cases.

  13.     while ($table = db_result($result)) {
          db_query("DROP TABLE IF EXISTS {$table}");
        }
    

    There is the function db_drop_table(), even if it is normally used on update functions; as alternative, it is possible to execute the query only after db_table_exists() returned TRUE.

  14. The file LICENSE.txt must be removed, as it is not possible to commit such file in CVS.
bob_hirnlego’s picture

There is the function db_drop_table(), even if it is normally used on update functions; as alternative, it is possible to execute the query only after db_table_exists() returned TRUE.

Unfortunately I need to drop tables specifing a certain prefix, and both db_drop_table() and db_table_exists() add it by their own means.
Solutions?

avpaderno’s picture

You can use @db_query('DROP TABLE {'. $table .'}'); that query is surely compatible with all the database engines that Drupal supports.

bob_hirnlego’s picture

Status: Needs work » Needs review
StatusFileSize
new40.64 KB

Here is the corrected version.

avpaderno’s picture

Status: Needs review » Needs work
  1. include_once("includes/hydra.inc");
    include_once("includes/hydra.api.inc");
    include_once("includes/hydra.rpc.inc");
    

    The current directory set when Drupal runs is the Drupal root directory; the paths used would not allow PHP to find the files.
    When a module needs to include code files, it should use module_load_include().

  2. Drupal coding standards report when to use a space before or after an operator; the code doesn't follow that recommendation.
    The coding standars also reports which functions should be called from a module.
  3. The node operations use the same label used by core node operations. Users would see two operations with the same description, and they would not know which one they are using.
  4. ; dependencies[] = hydra
    

    Such lines reports the dependency from other Drupal modules, not from external code. That line is commented out, but it should be removed as it could confuse the user.

bob_hirnlego’s picture

StatusFileSize
new39.66 KB

The node operations use the same label used by core node operations. Users would see two operations with the same description, and they would not know which one they are using.

Actually, the operations defined by Hydra override those defined by core. Users will not see duplicated labels.
This is necessary because of how contents are shared between sites.

New version attached.

avpaderno’s picture

Status: Needs work » Needs review
avpaderno’s picture

Status: Needs review » Fixed
  1. version = VERSION
    

    That line should be removed. The packaging script already adds a version line.

  2. Drupal modules are supposed to use the Drupal Unicode functions, which correctly handle the Unicode characters (differently from substr(), and strlen() (see http://drupal.org/node/473460).
bob_hirnlego’s picture

Status: Fixed » Needs review

I'm sorry if it's not the right place, but I've already sent a query using the contact form a few days ago and still received no answer.
I'll wait longer but I need to release this project fast.
The problem is the following:
I need to release this project (Hydra) using another Drupal account. I've already created it ("radioradicale").
The CVS account (that is "radioradicale" too) is correct, but would it be possible to assign it to the Drupal user "radioradicale"?
Forgive me for the trouble, but I'm bound to release Hydra with the other Drupal account.

avpaderno’s picture

I am not sure if what you are asking is acceptable; I would open a report in the Drupal.org webmasters queue, so that somebody could say if this is acceptable or not.
This issue queue is used from a minority of Drupal webmasters, and your request would not be much visible.

Also, you already used radioradicale as CVS username; it is not possible to change CVS username, but it is possible to swap it between two different users.

avpaderno’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

avpaderno’s picture

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

Status: Fixed » Closed (fixed)

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