Beispiel #1
0
 /**
  * Utility function to return the current module name
  * It first tries to get the name based on the table name,
  * and infer the name from the class name.  If neither of these
  * are appropriate, children should implement this function themselves.
  * or set _module_directory after construction.
  */
 public function getModuleName()
 {
     /* If we've already done this, or our sub-class has set this,
        we are on a winner */
     if (!empty($this->_module_directory)) {
         return $this->_module_directory;
     }
     /* Now the guessing game begins */
     $mods = new CModule();
     if (!empty($this->_permission_name)) {
         if ($mod_name = $mods->getModuleByName($this->_permission_name)) {
             $this->_module_directory = $mod_name;
             return $mod_name;
         }
     }
     $class = get_class($this);
     // Class usually includes an initial C and is camel case
     // And never is multibyte, so we are safe to use the non mb_ functions.
     $class = strtolower(substr($class, 1));
     if ($mod_name = $mods->getModuleByName($class)) {
         $this->_module_directory = $mod_name;
         return $mod_name;
     }
     return 'unknown';
 }