function loadDefinition()
 {
     $definitionFile = null;
     $pathList = eZModule::globalPathList();
     if ($pathList) {
         foreach ($pathList as $path) {
             $definitionFile = $path . '/' . $this->ModuleName . '/function_definition.php';
             if (file_exists($definitionFile)) {
                 break;
             }
             $definitionFile = null;
         }
     }
     if ($definitionFile === null) {
         eZDebug::writeError('Missing function definition file for module: ' . $this->ModuleName, 'eZModuleFunctionInfo::loadDefinition');
         return false;
     }
     unset($FunctionList);
     include $definitionFile;
     if (!isset($FunctionList)) {
         eZDebug::writeError('Missing function definition list for module: ' . $this->ModuleName, 'eZModuleFunctionInfo::loadDefinition');
         return false;
     }
     $this->FunctionList = $FunctionList;
     $this->IsValid = true;
     return true;
 }
 /**
  * Loads the operations definition for the current module
  * @return bool true if the operations were loaded, false if an error occured
  */
 function loadDefinition()
 {
     $pathList = eZModule::globalPathList();
     foreach ( $pathList as $path )
     {
         $definitionFile = $path . '/' . $this->ModuleName . '/operation_definition.php';
         if ( file_exists( $definitionFile ) )
             break;
         $definitionFile = null;
     }
     if ( $definitionFile === null )
     {
         eZDebug::writeError( 'Missing operation definition file for module: ' . $this->ModuleName, __METHOD__ );
         return false;
     }
     unset( $OperationList );
     include( $definitionFile );
     if ( !isset( $OperationList ) )
     {
         eZDebug::writeError( 'Missing operation definition list for module: ' . $this->ModuleName, __METHOD__ );
         return false;
     }
     $this->OperationList = $OperationList;
     $this->IsValid = true;
     return true;
 }
Пример #3
0
 /**
  * Finds all available modules in the system
  * @return array $modulename => $path
  */
 static function getModuleList()
 {
     $out = array();
     foreach (eZModule::globalPathList() as $path) {
         foreach (scandir($path) as $subpath) {
             if ($subpath != '.' && $subpath != '..' && is_dir($path . '/' . $subpath) && file_exists($path . '/' . $subpath . '/module.php')) {
                 $out[$subpath] = $path . '/' . $subpath . '/module.php';
             }
         }
     }
     return $out;
 }
Пример #4
0
 /**
  * Loads a module object by name.
  * The only difference with exists() is that the $module parameter will be
  * assigned the found module.
  *
  * @param string $moduleName The name of the module to find (ex: content)
  * @param mixed $module This parameter will receive the found module object
  * @param array|string
  *        Either an array of path or a single path string. These will be
  *        used as additionnal locations that will be looked into
  * @param boolean $showError
  *        If true an error will be shown if the module it not found.
  * @return eZModule The eZModule object, or null if the module wasn't found
  * @see exists()
  */
 static function findModule($moduleName, $module = null, $pathList = null, $showError = false)
 {
     if ($pathList === null) {
         $pathList = array();
     } else {
         if (!is_array($pathList)) {
             $pathList = array($pathList);
         }
     }
     $searchPathList = eZModule::globalPathList();
     if ($searchPathList === null) {
         $searchPathList = array();
     }
     $searchPathList = array_merge($searchPathList, $pathList);
     $triedList = array();
     $triedDirList = array();
     $foundADir = false;
     foreach ($searchPathList as $path) {
         $dir = "{$path}/{$moduleName}";
         $file = "{$dir}/module.php";
         if (file_exists($file)) {
             if ($module === null) {
                 $module = new eZModule($path, $file, $moduleName, false);
             } else {
                 $module->initialize($path, $file, $moduleName, false);
             }
             return $module;
         } else {
             if (!file_exists($dir)) {
                 $triedDirList[] = $dir;
             } else {
                 $foundADir = true;
                 $triedList[] = $dir;
             }
         }
     }
     $msg = "Could not find module named '{$moduleName}'";
     if ($foundADir) {
         $msg = "\nThese directories had a directory named '{$moduleName}' but did not contain the module.php file:\n" . implode(", ", $triedList) . "\n" . "This usually means it is missing or has a wrong name.";
         if (count($triedDirList) > 0) {
             $msg .= "\n\nThese directories were tried too but none of them exists:\n" . implode(', ', $triedDirList);
         }
     } else {
         if (count($triedDirList) > 0) {
             $msg .= "\nThese directories were tried but none of them exists:\n" . implode(", ", $triedDirList);
         }
     }
     if ($showError) {
         eZDebug::writeWarning($msg);
     }
     return null;
 }
Пример #5
0
    $cli->output();
}
$rows = eZPersistentObject::fetchObjectList(eZPolicy::definition(), array(), null, false, null, false, false, array(array('operation' => 'count( * )', 'name' => 'count')));
$total = $rows[0]['count'];
if (!$optDryRun) {
    $cli->output("{$total} policies to check... (In the progess bar, 'R' means that the policy was removed)");
} else {
    $cli->output("{$total} policies to check...");
}
if (!$optDryRun) {
    $script->setIterationData('R', '.');
    $script->resetIteration($total);
}
$limitation = array('offset' => 0, 'limit' => 100);
$db = eZDB::instance();
$modules = eZModule::globalPathList();
$removedPolicies = 0;
while (true) {
    $policies = eZPersistentObject::fetchObjectList(eZPolicy::definition(), null, null, null, $limitation, true);
    if (empty($policies)) {
        break;
    }
    foreach ($policies as $policy) {
        if ($policy->attribute('module_name') === '*') {
            continue;
        }
        $moduleExists = false;
        foreach ($modules as $module) {
            if (file_exists($module . '/' . $policy->attribute('module_name'))) {
                $moduleExists = true;
                break;