Ejemplo n.º 1
0
 public static function getInstance()
 {
     if (isset(self::$_instance)) {
         return self::$_instance;
     }
     $c = __CLASS__;
     self::$_instance = new $c();
     $res = db_query_params('SELECT r.role_id FROM pfo_role r, pfo_role_class c WHERE r.role_class = c.class_id AND c.class_name = "$1"', array('PFO_RoleAnonymous'));
     if (!$res || !db_numrows($res)) {
         throw new Exception("No PFO_RoleAnonymous role in the database");
     }
     self::$_instance->_role_id = db_result($res, 0, 'role_id');
     $hook_params = array();
     $hook_params['role'] =& self::$_instance;
     plugin_hook("role_get", $hook_params);
     self::$_instance->fetchData(self::$_instance->_role_id);
     return self::$_instance;
 }
Ejemplo n.º 2
0
$src_path = forge_get_config('src_path', 'mediawiki');
$master_path = forge_get_config('master_path', 'mediawiki');
// Get all projects that use the mediawiki plugin
$project_res = db_query_params("SELECT g.unix_group_name,g.group_id from groups g, group_plugin gp, plugins p where g.group_id = gp.group_id and gp.plugin_id = p.plugin_id and p.plugin_name = \$1;", array("mediawiki"));
if (!$project_res) {
    $err = "Error: Database Query Failed: " . db_error();
    cron_debug($err);
    cron_entry(23, $err);
    exit;
}
// Loop over all projects that use the plugin
while ($row = db_fetch_array($project_res)) {
    $project = $row['unix_group_name'];
    $project_id = $row['group_id'];
    $dump_file = forge_get_config('data_path') . "/plugins/mediawiki/dumps/{$project}.xml";
    $ra = RoleAnonymous::getInstance();
    if ($ra->hasPermission('plugin_mediawiki_read', $project_id)) {
        cron_debug("Dumping {$project}...");
        $mwwrapper = forge_get_config('source_path') . "/plugins/mediawiki/bin/mw-wrapper.php";
        $tmp = tempnam(forge_get_config('data_path') . "/plugins/mediawiki/dumps/", "tmp");
        system("{$mwwrapper} {$project} dumpBackup.php --current --quiet > {$tmp}");
        chmod($tmp, 0644);
        rename($tmp, $dump_file);
    } else {
        cron_debug("Not dumping {$project} (private)...");
        if (file_exists($dump_file)) {
            unlink($dump_file);
        }
    }
}
// Local Variables:
Ejemplo n.º 3
0
 public function getRoleById($role_id)
 {
     if (array_key_exists($role_id, $this->_cached_roles)) {
         return $this->_cached_roles[$role_id];
     }
     if (USE_PFO_RBAC) {
         $res = db_query_params('SELECT c.class_name, r.home_group_id FROM pfo_role r, pfo_role_class c WHERE r.role_class = c.class_id AND r.role_id = $1', array($role_id));
         if (!$res || !db_numrows($res)) {
             return NULL;
         }
         $class_id = db_result($res, 0, 'class_name');
         switch ($class_id) {
             case 'PFO_RoleExplicit':
                 $group_id = db_result($res, 0, 'home_group_id');
                 $group = group_get_object($group_id);
                 $this->_cached_roles[$role_id] = new Role($group, $role_id);
                 return $this->_cached_roles[$role_id];
             case 'PFO_RoleAnonymous':
                 $this->_cached_roles[$role_id] = RoleAnonymous::getInstance();
                 return $this->_cached_roles[$role_id];
             case 'PFO_RoleLoggedIn':
                 $this->_cached_roles[$role_id] = RoleLoggedIn::getInstance();
                 return $this->_cached_roles[$role_id];
             default:
                 throw new Exception("Not implemented");
         }
     } else {
         $res = db_query_params('SELECT group_id FROM role r WHERE role_id = $1', array($role_id));
         if (!$res || !db_numrows($res)) {
             return NULL;
         }
         $group_id = db_result($res, 0, 'group_id');
         $group = group_get_object($group_id);
         return new Role($group, $role_id);
     }
 }