/**
  * Diese statische Methode bestimmt, in welchem Newsletter der uebergebene
  * Newsletter-Entry ist.
  * @param int $entry_id die ID des Newsletter-Eintrags
  * @return int die ID des Newsletters oder <i>null</i>
  */
 public static function get_newsletter_id_for_entry($entry_id)
 {
     $rueckgabe = null;
     $db = new DbPdo();
     $sql = "SELECT newsletterContId FROM " . PREFIX . "newsletterEntries WHERE id=:entry_id;";
     $erg = $db->prepare_and_execute($sql, array("entry_id" => $entry_id));
     if (is_array($erg) && count($erg) == 1) {
         $rueckgabe = $erg[0]['newsletterContId'];
     }
     return $rueckgabe;
 }
 public static function getDefaultUserGroupForNewUsers()
 {
     $db = new DbPdo();
     $sql = "SELECT * FROM " . PREFIX . "newsletterGroups WHERE specialGroup=?;";
     $result = $db->prepare_and_execute($sql, array(self::NEWSLETTER_GROUP_TYPE_NEW_USERS));
     if (isset($result[0]['id'])) {
         return $result[0]['id'];
     }
     return false;
 }
/**
 * Hilfsfunktion zum Auslesen aller noch "unerledigten" Updates
 * @param string $update_dir absoluter Pfad zum Updates-Verzeichnis
 * @param DbPdo $db eine offene Datenbankverbindung
 * @return array list of filenames
 */
function get_updates_to_do($update_dir, $db)
{
    $filenames = array();
    // get all available updates from updates directory
    $update_dir_handle = opendir($update_dir);
    if ($update_dir_handle) {
        $filenames['update_files'] = array();
        while ($update_file = readdir($update_dir_handle)) {
            if ($update_file != "update.css" && !is_dir($update_file) && $update_file[0] != ".") {
                $filenames['update_files'][] = $update_file;
            }
        }
    }
    unset($update_file);
    closedir($update_dir_handle);
    // set defaults for backwards compatibility
    $filenames['migrations_done'] = array();
    $filenames['updates_to_do'] = $filenames['update_files'];
    if ($db->table_exists("migrations")) {
        $sql = "SELECT * FROM " . PREFIX . "migrations";
        $result = $db->prepare_and_execute($sql);
        $filenames['migrations_done'] = array();
        foreach ($result as $migration_done) {
            $filenames['migrations_done'][] = $migration_done['filename'];
        }
        $filenames['updates_to_do'] = array_diff($filenames['update_files'], $filenames['migrations_done']);
    }
    sort($filenames['updates_to_do']);
    sort($filenames['update_files']);
    sort($filenames['migrations_done']);
    return $filenames;
}