Don't like ads? PRO users don't see any ads ;-)
Guest

ma fonction

By: a guest on Apr 25th, 2012  |  syntax: PHP  |  size: 1.44 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function mod_install($db_update_mode, $install_error)
  2. {
  3.         global $user, $db, $cache, $auth;
  4.         $auth_admin = new auth_admin();
  5.         $mod_sql_data = array(
  6.                 'perm_name'                     => 'acl_m_user_notes',
  7.                 'short_perm_name'               => 'm_user_notes',
  8.                 'mod_basename'                  => 'notes',
  9.                 'config_name'                   => 'mod_munp_version',
  10.                 'config_version'                => '1.0.1',
  11.         );
  12.         switch($db_update_mode)
  13.         {
  14.         case'install_mod':
  15. //Install Step         
  16.         $sql = 'UPDATE ' . MODULES_TABLE . "
  17.                                         SET module_auth = 'acl_m_user_notes'
  18.                                         WHERE module_basename LIKE 'MCP_NOTES_%'";
  19.                 $db->sql_query($sql);
  20.                 if (!permission_exists($mod_sql_data['short_perm_name'], true))
  21.                 {      
  22.                 $auth_admin->acl_add_option(array(
  23.                                         'local'     => array(),
  24.                                         'global'        => array($mod_sql_data['short_perm_name']),
  25.                                 ));    
  26.                 }                              
  27.                 set_config($mod_sql_data['config_name'], $mod_sql_data['config_version'], false); //Mod version
  28.                 $cache->purge();
  29.                 $install_error = false;//Ok if we are here no error occured... so $install_error is false      
  30.         break;
  31.         case'remove_mod':              
  32. //Uninstall step
  33.         $sql = 'UPDATE ' . MODULES_TABLE . "
  34.                                         SET module_auth = ''
  35.                                         WHERE module_basename LIKE 'MCP_NOTES_%'";
  36.         $db->sql_query($sql);
  37.         $sql = 'DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = '" . $db->sql_escape($mod_sql_data['config_name']) . "'";
  38.         $db->sql_query($sql);
  39.                 $cache->purge();       
  40.                 $install_error = false; //Ok if we are here no error occured... so $install_error is false     
  41.         break;
  42.         }
  43. }