Ejemplo n.º 1
0
 public function execute($last_result, $parameters = array())
 {
     $db = DBManager::get();
     $dd_func = function ($d) {
         delete_document($d);
     };
     //abgelaufenen News löschen
     $deleted_news = StudipNews::DoGarbageCollect();
     //messages aufräumen
     $to_delete = $db->query("SELECT message_id, count( message_id ) AS gesamt, count(IF (deleted =0, NULL , 1) ) AS geloescht\n                FROM message_user GROUP BY message_id HAVING gesamt = geloescht")->fetchAll(PDO::FETCH_COLUMN, 0);
     if (count($to_delete)) {
         $db->exec("DELETE FROM message_user WHERE message_id IN(" . $db->quote($to_delete) . ")");
         $db->exec("DELETE FROM message WHERE message_id IN(" . $db->quote($to_delete) . ")");
         $to_delete_attach = $db->query("SELECT dokument_id FROM dokumente WHERE range_id IN(" . $db->quote($to_delete) . ")")->fetchAll(PDO::FETCH_COLUMN, 0);
         array_walk($to_delete_attach, $dd_func);
     }
     //Attachments von nicht versendeten Messages aufräumen
     $to_delete_attach = $db->query("SELECT dokument_id FROM dokumente WHERE range_id = 'provisional' AND chdate < UNIX_TIMESTAMP(DATE_ADD(NOW(),INTERVAL -2 HOUR))")->fetchAll(PDO::FETCH_COLUMN, 0);
     array_walk($to_delete_attach, $dd_func);
     if ($parameters['verbose']) {
         printf(_("Gelöschte Ankündigungen: %u") . "\n", (int) $deleted_news);
         printf(_("Gelöschte Nachrichten: %u") . "\n", count($to_delete));
         printf(_("Gelöschte Dateianhänge: %u") . "\n", count($to_delete_attach));
     }
     PersonalNotifications::doGarbageCollect();
     // Remove old plugin assets
     PluginAsset::deleteBySQL('chdate < ?', array(time() - PluginAsset::CACHE_DURATION));
 }
Ejemplo n.º 2
0
list($type, $id) = explode('/', $uri);
// Setup response
$response = new RESTAPI\Response();
// Create response
if (!$type || !$id) {
    // Invalid call
    $response->status = 400;
} elseif ($type !== 'css') {
    // Invalid type
    $response->status = 501;
} elseif (!PluginAsset::exists($id)) {
    // Asset does not exist
    $response->status = 404;
} else {
    // Load asset
    $model = PluginAsset::find($id);
    if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] && $model->chdate <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
        // Cached and still valid
        $response->status = 304;
    } else {
        // Output asset
        $asset = new Assets\PluginAsset($model);
        $response->body = $asset->getContent();
        if ($response->body === false) {
            // Could not obtain asset contents
            $response->status = 500;
        } else {
            // Set appropriate header
            $response['Content-Type'] = 'text/css';
            $response['Content-Length'] = $model->size;
            $response['Content-Disposition'] = 'inline;filename="' . $model->filename . '"';
Ejemplo n.º 3
0
 /**
  * Uninstall the given plugin from the system. It will remove
  * the database schema and all the plugin's files.
  *
  * @param array $plugin meta data of plugin
  */
 public function uninstallPlugin($plugin)
 {
     $plugin_manager = PluginManager::getInstance();
     // check if there are dependent plugins
     foreach ($plugin_manager->getPluginInfos() as $dep_plugin) {
         if ($dep_plugin['depends'] === $plugin['id']) {
             $plugin_manager->unregisterPlugin($dep_plugin['id']);
         }
     }
     $plugin_manager->unregisterPlugin($plugin['id']);
     $plugindir = get_config('PLUGINS_PATH') . '/' . $plugin['path'];
     $manifest = $plugin_manager->getPluginManifest($plugindir);
     // delete database if needed
     $this->deleteDBSchema($plugindir, $manifest);
     PluginAsset::deleteBySQL('plugin_id = ?', array($plugin['id']));
     rmdirr($plugindir);
 }