Пример #1
0
function do_cron()
{
    global $config;
    ct_log("Cron-Job started.", 2, -1, 'cron');
    $btns = churchcore_getModulesSorted(false, false);
    foreach ($btns as $key) {
        include_once constant(strtoupper($key)) . "/{$key}.php";
        if (function_exists($key . "_cron")) {
            if (isset($config[$key . "_name"]) && $config[$key . "_name"] != "") {
                $arr = call_user_func($key . "_cron");
            }
        }
    }
    ct_sendPendingNotifications();
    ct_log("Cron-Job finished.", 2, -1, 'cron');
}
 /**
  *
  * @see CTModuleInterface::getMasterData()
  */
 public function getMasterData()
 {
     global $user, $base_url, $files_dir, $config;
     $res["modulename"] = "churchcore";
     $modules = churchcore_getModulesSorted();
     if (in_array("churchdb", $modules)) {
         include_once './' . CHURCHDB . '/churchdb_db.php';
         $res["mygroups"] = churchdb_getMyGroups($user->id, false, false);
         foreach ($res["mygroups"] as $g) {
             if (!isset($g->status_no) || $g != null && $g->members_allowedmail_eachother_yn == 0 && $g->status_no != 1 && $g->status_no != 2) {
                 unset($res["mygroups"][$g->id]);
             }
         }
     }
     if (in_array("churchcal", $modules)) {
         include_once './' . CHURCHCAL . '/churchcal_db.php';
         $res["meetingRequests"] = churchcal_getMyMeetingRequest();
     }
     return $res;
 }
Пример #3
0
/**
 * execute cron job for all modules
 */
function do_cron()
{
    global $files_dir;
    ct_log("Cron-Job started.", 2, -1, 'cron');
    //delete temporary files (and sessions) older than one day
    $tempDir = $files_dir . '/tmp/';
    foreach (array_slice(scandir($tempDir), 2) as $file) {
        $path = $tempDir . $file;
        if (is_file($path) && filemtime($path) < time() - 3600 * 24) {
            unlink($path);
        }
    }
    //launch the cronjobs of the individual CT modules
    $modulesSorted = churchcore_getModulesSorted(false, false);
    foreach ($modulesSorted as $key) {
        include_once constant(strtoupper($key)) . "/{$key}.php";
        if (function_exists($key . "_cron") && getConf($key . "_name")) {
            call_user_func($key . "_cron");
        }
    }
    ct_sendPendingNotifications();
    ct_log("Cron-Job finished.", 2, -1, 'cron');
}
Пример #4
0
function home_main()
{
    global $config, $files_dir, $mapping;
    if ($m = readConf("admin_message")) {
        addErrorMessage($m);
    }
    checkFilesDir();
    $btns = churchcore_getModulesSorted();
    if (isset($_SESSION["family"])) {
        addInfoMessage(t('there.are.more.users.with.the.same.email'));
    }
    $txt = '
  <div class="hero-unit hidden-phone">
    <h1>' . $config["welcome"] . '</h1>
    <p class="hidden-phone">' . $config["welcome_subtext"] . '</p>
    <p>';
    foreach ($btns as $key) {
        if (isset($config[$key . "_startbutton"]) && $config[$key . "_startbutton"] == "1" && user_access("view", $key)) {
            $txt .= '<a class="btn btn-large" href="?q=' . $key . '">' . $config[$key . "_name"] . '</a>&nbsp;';
        }
    }
    $txt .= '</p>';
    $txt .= '</div>';
    $txt .= '<div class="well visible-phone">
    <h1>' . t("welcome") . '!</h1>
    <p>' . $_SESSION["user"]->vorname . ', ' . t("chose.your.possibilities") . ':</p>
    <ul class="nav nav-pills nav-stacked">';
    foreach ($btns as $key) {
        if (isset($config[$key . "_name"]) && $config[$key . "_name"] != "" && user_access("view", $key)) {
            include_once SYSTEM . '/' . $mapping[$key];
            $txt .= '<li><a class="btn btn-large" href="?q=' . $key . '">' . $config[$key . "_name"] . '</a> ';
        }
    }
    $txt .= '</ul>';
    $txt .= '</div>';
    // blocks[]: label, col(1,2,3) sortkey, html
    $blocks = null;
    foreach ($btns as $key) {
        if (!empty($config[$key . "_name"])) {
            include_once SYSTEM . '/' . $mapping[$key];
            if (function_exists($key . "_blocks")) {
                $b = call_user_func($key . "_blocks");
                foreach ($b as $block) {
                    $blocks[$block["col"]][] = $block;
                }
            }
        }
    }
    $txt .= '<div class="row-fluid">';
    for ($i = 1; $i <= 3; $i++) {
        $txt .= '<ul class="span4">';
        if (isset($blocks[$i])) {
            churchcore_sort($blocks[$i], "sortkey");
            foreach ($blocks[$i] as $block) {
                if ($block["html"] != null && $block["html"] != "") {
                    $txt .= '<li class="ct_whitebox';
                    if (isset($block["class"])) {
                        $txt .= ' ' . $block["class"];
                    }
                    $txt .= '">';
                    $txt .= '<label class="ct_whitebox_label">' . $block["label"] . "</label>";
                    if (isset($block["help"])) {
                        $txt .= '<div style="float:right;margin:-34px -12px">';
                        $txt .= '<a href="http://intern.churchtools.de?q=help&doc=' . $block["help"] . '" title="' . t("open.help") . '" target="_clean"><i class="icon-question-sign"></i></a>';
                        $txt .= '</div>';
                    }
                    $txt .= $block["html"];
                }
            }
        }
        $txt .= '</ul>';
    }
    $txt .= '</div>';
    drupal_add_js(MAIN . '/home.js');
    return $txt;
}
Пример #5
0
/**
 *
 * @return array
 */
function getAuthTable()
{
    $modules = churchcore_getModulesSorted(true, false);
    $auth = array();
    $sortkey = 0;
    foreach ($modules as $module) {
        include_once "system/{$module}/{$module}.php";
        if (function_exists($module . "_getAuth")) {
            $res = call_user_func($module . "_getAuth");
            foreach ($res as $key => $val) {
                $val->sortkey = $sortkey;
                $sortkey++;
                $auth[$key] = $val;
            }
        }
    }
    return $auth;
}
Пример #6
0
               <?php 
     echo '<li ';
     if ($q == "login") {
         echo ' class="active"';
     }
     echo '><a href="?q=login"><i class="icon-user icon-white"></i> ' . t("login") . '</a></li>';
     ?>
            </ul>
          </div>
          <?php 
 }
 ?>
           <div class="nav-collapse">
             <ul class="nav">
               <?php 
 $arr = churchcore_getModulesSorted();
 foreach ($arr as $key) {
     if (readConf($key . "_name") && readConf($key . "_inmenu") == "1" && (user_access("view", $key) || in_array($key, $mapping["page_with_noauth"]))) {
         echo "<li ";
         if ($q == $key) {
             echo 'class="active"';
         }
         echo '><a href="?q=' . $key . '">';
         echo $config[$key . "_name"];
         echo "</a></li>" . NL;
     }
 }
 ?>
               
             </ul>
               <!--form class="navbar-search pull-right">
 /**
  * get MasterData
  *
  * @return array with objects
  *
  */
 public function getMasterData()
 {
     global $config;
     $res = array();
     $res["auth_table_plain"] = getAuthTable();
     foreach ($res["auth_table_plain"] as $auth) {
         if ($auth->datenfeld && !isset($res[$auth->datenfeld])) {
             $res[$auth->datenfeld] = churchcore_getTableData($auth->datenfeld);
         }
     }
     $res["modules"] = churchcore_getModulesSorted(true, false);
     $res["person"] = churchcore_getTableData("cdb_person", "name, vorname", null, "id, concat(name, ', ', vorname) as bezeichnung");
     $res["person"][-1] = new stdClass();
     $res["person"][-1]->id = -1;
     $res["person"][-1]->bezeichnung = "- " . t("public.user") . " -";
     $res["publiccalendar_name"] = getConf("churchcal_maincalname", "Church Calendar");
     $res["gruppe"] = churchcore_getTableData("cdb_gruppe", null, null, "id, bezeichnung");
     $res["status"] = churchcore_getTableData("cdb_status");
     $res["category"] = churchcore_getTableData("cc_calcategory", null, null, "id, bezeichnung, privat_yn, oeffentlich_yn");
     $res["modulename"] = "churchcore";
     $res["admins"] = $config["admin_ids"];
     $auths = churchcore_getTableData("cc_domain_auth");
     if ($auths) {
         foreach ($auths as $auth) {
             $domaintype = array();
             // initalize $res[domain_tye]
             if (isset($res[$auth->domain_type])) {
                 $domaintype = $res[$auth->domain_type];
             }
             $object = new stdClass();
             if (isset($domaintype[$auth->domain_id])) {
                 $object = $domaintype[$auth->domain_id];
             } else {
                 $object->id = $auth->domain_id;
                 if (isset($db[$auth->domain_type][$auth->domain_id])) {
                     $object->bezeichnung = $db[$auth->domain_type][$auth->domain_id]->bezeichnung;
                 } else {
                     $object->bezeichnung = t("non.existent");
                 }
             }
             if ($auth->daten_id == null) {
                 $object->auth[$auth->auth_id] = $auth->auth_id;
             } else {
                 if (!isset($object->auth[$auth->auth_id])) {
                     $object->auth[$auth->auth_id] = array();
                 }
                 $object->auth[$auth->auth_id][$auth->daten_id] = $auth->daten_id;
             }
             $domaintype[$auth->domain_id] = $object;
             $res[$auth->domain_type] = $domaintype;
         }
     }
     foreach (churchcore_getModulesSorted() as $name) {
         if (isset($config[$name . "_name"])) {
             $res["names"][$name] = $config[$name . "_name"];
         }
     }
     return $res;
 }
Пример #8
0
/**
 * home main function
 *
 * @return string html content
 */
function home_main()
{
    global $config, $files_dir, $mapping;
    if ($m = getConf("admin_message")) {
        addErrorMessage($m);
    }
    checkFilesDir();
    $modules = churchcore_getModulesSorted();
    if (isset($_SESSION["family"])) {
        addInfoMessage(t('there.are.more.users.with.the.same.email'));
    }
    // Start buttons for Desktop-View
    $txt = '
  <div class="hero-unit hidden-phone">
    <h1>' . getVar("welcome", "", $config) . '</h1>
    <p class="hidden-phone">' . getVar("welcome_subtext", "", $config) . '</p>
    <p>';
    // module buttons normal
    foreach ($modules as $m) {
        if (getConf($m . "_startbutton") && user_access("view", $m)) {
            $txt .= "<a class='btn btn-large' href='?q={$m}'>" . $config[$m . "_name"] . '</a>&nbsp;';
        }
    }
    $txt .= '
    </p>
  </div>';
    // Start buttons for Mobile-View
    $txt .= '
  <div class="well visible-phone">
    <h1>' . t("welcome") . '!</h1>
    <p>' . $_SESSION["user"]->vorname . ', ' . t("chose.your.possibilities") . ':</p>
    <ul class="nav nav-pills nav-stacked">';
    // module buttons mobile
    foreach ($modules as $m) {
        if (getConf($m . "_name") && getConf($m . "_startbutton") == "1" && user_access("view", $m)) {
            $txt .= "<li><a class='btn btn-large' href='?q={$m}'>" . $config[$m . "_name"] . '</a> ';
        }
    }
    $txt .= '</ul>' . NL;
    $txt .= '</div>' . NL;
    // blocks[]: label, col(1,2,3) sortkey, html
    $blocks = null;
    foreach ($modules as $m) {
        if (getConf($m . "_name")) {
            include_once SYSTEM . '/' . $mapping[$m];
            //TODO: this functions are actually only config arrays - handle them as such and put them on a place a admin may even change them.
            if (function_exists($m . "_blocks")) {
                $b = call_user_func($m . "_blocks");
                foreach ($b as $block) {
                    $blocks[$block["col"]][] = $block;
                }
            }
        }
    }
    $txt .= '<div class="row-fluid">';
    for ($i = 1; $i <= 3; $i++) {
        $txt .= '<ul class="span4">';
        if (isset($blocks[$i])) {
            churchcore_sort($blocks[$i], "sortkey");
            //TODO: why not put them in the right order where they are defined?
            foreach ($blocks[$i] as $block) {
                if ($block["html"]) {
                    $txt .= '<li class="ct_whitebox ' . $block["class"] . '">';
                    $txt .= '<label class="ct_whitebox_label">' . $block["label"] . "</label>";
                    if (isset($block["help"])) {
                        $txt .= '<div style="float:right;margin:-34px -12px">';
                        $txt .= '<a href="http://intern.churchtools.de?q=help&doc=' . $block["help"] . '" title="' . t("open.help") . '" target="_clean"><i class="icon-question-sign"></i></a>';
                        $txt .= '</div>';
                    }
                    $txt .= $block["html"];
                }
            }
        }
        $txt .= '</ul>' . NL;
    }
    $txt .= '</div>' . NL;
    drupal_add_js(MAIN . '/home.js');
    return $txt;
}
Пример #9
0
function churchcal_updateEvent($params, $source = null)
{
    $arr = array();
    // Store all Exception and Addition changes for communication to other modules
    $changes = array();
    // Nur Rechte pr�fen, wenn ich source bin, denn sonst hat das das Ursprungsmodul schon erledigt
    if ($source == null) {
        // Pr�fe, ob ich auf neue Kategorie schrieben darf
        if (!churchcal_isAllowedToEditCategory($params["category_id"])) {
            return CTNoPermission("AllowedToEditCategory[" . $params["category_id"] . "]", "churchcal");
        }
        // Pr�fe, ob ich auf die vorhandene Kategorie schreiben darf
        $old_cal = db_query("select category_id, startdate from {cc_cal} where id=:id", array(":id" => $params["id"]))->fetch();
        if (!churchcal_isAllowedToEditCategory($old_cal->category_id)) {
            return CTNoPermission("AllowedToEditCategory[" . $old_cal->category_id . "]", "churchcal");
        }
    }
    // Wenn es nur eine Verschiebung auf dem Kalender ist
    if (!isset($params["repeat_id"])) {
        $i = new CTInterface();
        $i->setParam("startdate", false);
        $i->setParam("enddate", false);
        $i->setParam("bezeichnung", false);
        $i->setParam("category_id", false);
        if (count($i->getDBInsertArrayFromParams($params)) > 0) {
            db_update("cc_cal")->fields($i->getDBInsertArrayFromParams($params))->condition("id", $params["id"], "=")->execute();
        }
    } else {
        $arr[":event_id"] = $params["id"];
        $arr[":startdate"] = $params["startdate"];
        $arr[":enddate"] = $params["enddate"];
        $arr[":bezeichnung"] = $params["bezeichnung"];
        $arr[":ort"] = $params["ort"];
        $arr[":intern_yn"] = $params["intern_yn"];
        $arr[":notizen"] = str_replace('\\"', '"', $params["notizen"]);
        $arr[":link"] = $params["link"];
        $arr[":category_id"] = $params["category_id"];
        if (isset($params["repeat_id"])) {
            $arr[":repeat_id"] = $params["repeat_id"];
        } else {
            $arr[":repeat_id"] = null;
        }
        if (isset($params["repeat_until"])) {
            $arr[":repeat_until"] = $params["repeat_until"];
        } else {
            $arr[":repeat_until"] = null;
        }
        if (isset($params["repeat_frequence"])) {
            $arr[":repeat_frequence"] = $params["repeat_frequence"];
        } else {
            $arr[":repeat_frequence"] = null;
        }
        if (isset($params["repeat_option_id"])) {
            $arr[":repeat_option_id"] = $params["repeat_option_id"];
        } else {
            $arr[":repeat_option_id"] = null;
        }
        db_query("update {cc_cal} set startdate=:startdate, enddate=:enddate, bezeichnung=:bezeichnung, ort=:ort,\n      notizen=:notizen, link=:link, category_id=:category_id, intern_yn=:intern_yn, category_id=:category_id, \n      repeat_id=:repeat_id, repeat_until=:repeat_until, repeat_frequence=:repeat_frequence,\n      repeat_option_id=:repeat_option_id \n        where id=:event_id", $arr);
        // Hole alle Exceptions aus der DB
        $exc = churchcore_getTableData("cc_cal_except", null, "cal_id=" . $params["id"]);
        // Vergleiche erst mal welche schon in der DB sind oder noch nicht in der DB sind.
        if (isset($params["exceptions"])) {
            foreach ($params["exceptions"] as $exception) {
                if ($exception["id"] > 0) {
                    $exc[$exception["id"]]->vorhanden = true;
                } else {
                    $add_exc = array("cal_id" => $params["id"], "except_date_start" => $exception["except_date_start"], "except_date_end" => $exception["except_date_end"]);
                    churchcal_addException($add_exc);
                    $changes["add_exception"][] = $add_exc;
                }
            }
        }
        // L�sche nun alle, die in der DB sind, aber nicht mehr vorhanden sind.
        if ($exc != false) {
            foreach ($exc as $e) {
                if (!isset($e->vorhanden)) {
                    $del_exc = array("id" => $e->id, "except_date_start" => $e->except_date_start, "except_date_end" => $e->except_date_end);
                    churchcal_delException($del_exc);
                    $changes["del_exception"][] = $del_exc;
                }
            }
        }
        // Hole alle Additions aus der DB
        $add = churchcore_getTableData("cc_cal_add", null, "cal_id=" . $params["id"]);
        // Vergleiche erst mal welche schon in der DB sind oder noch nicht in der DB sind.
        if (isset($params["additions"])) {
            foreach ($params["additions"] as $addition) {
                if ($addition["id"] > 0) {
                    $add[$addition["id"]]->vorhanden = true;
                } else {
                    $add_add = array("cal_id" => $params["id"], "add_date" => $addition["add_date"], "with_repeat_yn" => $addition["with_repeat_yn"]);
                    churchcal_addAddition($add_add);
                    $changes["add_addition"][] = $add_add;
                }
            }
        }
        // L�sche nun alle, die in der DB sind, aber nicht mehr vorhanden sind.
        if ($add != false) {
            foreach ($add as $a) {
                if (!isset($a->vorhanden)) {
                    $del_add = array("id" => $a->id, "add_date" => $a->add_date);
                    churchcal_delAddition($del_add);
                    $changes["del_addition"][] = $del_add;
                }
            }
        }
    }
    // MeetingRequest
    if (isset($params["meetingRequest"])) {
        churchcal_handleMeetingRequest($params["id"], $params);
    }
    // BENACHRICHTIGE ANDERE MODULE
    $modules = churchcore_getModulesSorted(false, false);
    if (in_array("churchresource", $modules) && ($source == null || $source != "churchresource")) {
        include_once CHURCHRESOURCE . '/churchresource_db.php';
        if ($source == null) {
            $source = "churchcal";
        }
        $params["cal_id"] = $params["id"];
        churchresource_updateResourcesFromChurchCal($params, $source, $changes);
    }
    if (in_array("churchservice", $modules) && ($source == null || $source != "churchservice")) {
        include_once CHURCHSERVICE . '/churchservice_db.php';
        $cs_params = array_merge(array(), $params);
        $cs_params["cal_id"] = $params["id"];
        $cs_params["id"] = null;
        $cs_params["old_startdate"] = $old_cal->startdate;
        if ($source == null) {
            $source = "churchcal";
        }
        churchservice_updateEventFromChurchCal($cs_params, $source);
    }
}
Пример #10
0
/**
 * Load url mappings for each module and merge them together
 * module map path like like system/churchdb/churchdb.mapping
 *
 * @return array
 */
function loadMapping()
{
    $map = parse_ini_file(SYSTEM . "/churchtools.mapping");
    foreach (churchcore_getModulesSorted(true) as $module) {
        if (file_exists(SYSTEM . "/{$module}/{$module}.mapping")) {
            $modMap = parse_ini_file(SYSTEM . "/{$module}/{$module}.mapping");
            if (isset($modMap["page_with_noauth"]) && isset($map["page_with_noauth"])) {
                $modMap["page_with_noauth"] = array_merge($modMap["page_with_noauth"], $map["page_with_noauth"]);
            }
            $map = array_merge($map, $modMap);
        }
    }
    return $map;
}
Пример #11
0
        ?>
>
                <a href="?q=login"><i class="icon-user icon-white"></i>&nbsp;<?php 
        echo t("login");
        ?>
</a>
              </li>
           </ul>
         </div>
  <?php 
    }
    ?>
          <div class="nav-collapse">
            <ul class="nav">
  <?php 
    foreach (churchcore_getModulesSorted() as $key) {
        ?>
    <?php 
        if (getConf($key . "_name") && getConf($key . "_inmenu") == "1" && (user_access("view", $key) || in_array($key, $mapping["page_with_noauth"]))) {
            ?>
                <li <?php 
            echo $q == $key ? 'class="active"' : "";
            ?>
>
                <a href="?q=<?php 
            echo $key;
            ?>
"><?php 
            echo getConf($key . "_name");
            ?>
</a></li>
Пример #12
0
function admin_main()
{
    global $config;
    drupal_add_css(ASSETS . '/fileuploader/fileuploader.css');
    drupal_add_js(ASSETS . '/fileuploader/fileuploader.js');
    $model = new CTForm("AdminForm", "admin_saveSettings");
    $model->addField("site_name", "", "INPUT_REQUIRED", t("name.of.website"))->setValue($config["site_name"]);
    $model->addField("site_logo", "", "FILEUPLOAD", t("logo.of.website"))->setValue(readConf("site_logo"));
    $model->addField("welcome", "", "INPUT_REQUIRED", t("welcome.message"));
    $model->fields["welcome"]->setValue($config["welcome"]);
    $model->addField("welcome_subtext", "", "INPUT_REQUIRED", "Untertitel der Willkommensnachricht");
    $model->fields["welcome_subtext"]->setValue($config["welcome_subtext"]);
    $model->addField("login_message", "", "INPUT_REQUIRED", "Willkommensnachricht vor dem Login");
    $model->fields["login_message"]->setValue($config["login_message"]);
    $model->addField("invite_email_text", "", "TEXTAREA", "Text der Einladungs-EMail");
    $model->fields["invite_email_text"]->setValue($config["invite_email_text"]);
    $model->addField("admin_message", "", "INPUT_OPTIONAL", "Admin-Nachricht auf Login- und Startseite z.B. f&uuml;r geplante Downtimes");
    $model->fields["admin_message"]->setValue(variable_get("admin_message", ""));
    if (!isset($config["site_startpage"])) {
        $config["site_startpage"] = "home";
    }
    $model->addField("site_startpage", "", "INPUT_REQUIRED", "Startseite beim Aufrufen von " . variable_get("site_name") . " (Standard ist <i>home</i>, m&ouml;glich ist z.B. churchwiki, churchcal)");
    $model->fields["site_startpage"]->setValue($config["site_startpage"]);
    $model->addField("site_mail", "", "EMAIL", "E-Mail-Adresse der Website (E-Mails werden von hier aus gesendet)");
    $model->fields["site_mail"]->setValue($config["site_mail"]);
    if (!isset($config["admin_mail"])) {
        $config["admin_mail"] = $config["site_mail"];
    }
    $model->addField("admin_mail", "", "EMAIL", "E-Mail-Adressen der Admins f&uuml;r Anfragen von Benutzern (Kommasepariert)");
    $model->fields["admin_mail"]->setValue($config["admin_mail"]);
    // Now iterate through each module for naming the module
    $modules = churchcore_getModulesSorted(false, true);
    foreach ($modules as $module) {
        $model->addField($module . "_name", "", "INPUT_OPTIONAL", "Name f&uuml;r <i>{$module}</i> (Bitte Feld leerlassen, wenn das Modul nicht ben&ouml;tigt wird)");
        $model->fields[$module . "_name"]->setValue(variable_get($module . "_name", ""));
    }
    $model->addField("max_uploadfile_size_kb", "", "INPUT_REQUIRED", "Maximale Upload-Dateigr&ouml;sse in Kilobytes (z.B. 10MB entsprechen hier ca. 10000)");
    $model->fields["max_uploadfile_size_kb"]->setValue($config["max_uploadfile_size_kb"]);
    $model->addField("cronjob_delay", "", "INPUT_REQUIRED", "Zeit in Sekunden zwischen automatischen Cronjob (0=kein automatischer Cron, sinnvolle Werte z.B. 3600)");
    $model->fields["cronjob_delay"]->setValue($config["cronjob_delay"]);
    $model->addField("timezone", "", "INPUT_REQUIRED", "Standard-Zeitzone. Z.b. Europe/Berlin");
    $model->fields["timezone"]->setValue($config["timezone"]);
    $model->addField("show_remember_me", "", "CHECKBOX", "Anzeige von <i>Zuk&uuml;nftig an mich erinnern</i> auf der Login-Seite");
    $model->fields["show_remember_me"]->setValue($config["show_remember_me"]);
    $model->addField("mail_enabled", "", "CHECKBOX", "Senden von E-Mails erlauben");
    $model->fields["mail_enabled"]->setValue($config["mail_enabled"]);
    $model->addField("site_offline", "", "CHECKBOX", "Seite offline schalten");
    $model->fields["site_offline"]->setValue($config["site_offline"]);
    $model->addButton("Speichern", "ok");
    $txtCommonForm = $model->render();
    // Now iterate through each module getting the admin forms
    $m = array();
    foreach ($modules as $module) {
        include_once constant(strtoupper($module)) . "/{$module}.php";
        if (function_exists($module . "_getAdminForm")) {
            $model = call_user_func($module . "_getAdminForm");
            if ($model != null) {
                $m[$module] = $model->render();
            }
        }
    }
    $txt = '<h1>' . t("settings.for", variable_get("site_name")) . '</h1><p>Der Administrator kann hier Einstellung vornehmen. Diese gelten f&uuml;r alle Benutzer, bitte vorsichtig anpassen!</p>';
    $txt .= '<div class="tabbable">';
    $txt .= '<ul class="nav nav-tabs">';
    $txt .= '<li class="active"><a href="#tab1" data-toggle="tab">' . t("general") . '</a></li>';
    foreach ($modules as $module) {
        if (isset($m[$module]) && isset($config[$module . "_name"]) && $config[$module . "_name"] != "") {
            $txt .= '<li><a href="#tab' . $module . '" data-toggle="tab">' . $config[$module . "_name"] . '</a></li>';
        }
    }
    $txt .= '</ul>';
    $txt .= '<div class="tab-content">';
    $txt .= '<div class="tab-pane active" id="tab1">';
    $txt .= $txtCommonForm;
    $txt .= '</div>';
    foreach ($modules as $module) {
        if (isset($m[$module])) {
            $txt .= '<div class="tab-pane" id="tab' . $module . '">';
            $txt .= $m[$module];
            $txt .= '</div>';
        }
    }
    $txt .= '</div></div>';
    return $txt;
}
Пример #13
0
/**
 * save admin settings and reload config
 *
 * TODO: feature: automatically downsize logo file
 *
 * @param CTForm $form
 */
function admin_saveSettings($form)
{
    $modules = churchcore_getModulesSorted(false, true);
    $modules[] = "churchadmin";
    foreach ($modules as $module) {
        foreach ($form->fields as $key => $value) {
            if (function_exists($module . "_validateAdminForm")) {
                $res = call_user_func($module . "_validateAdminForm", $key, $value->getValue());
                if ($res !== true) {
                    $form->fields[$key]->setError($res);
                    addErrorMessage(t("error.occured") . ": " . $res);
                    return;
                }
            }
        }
    }
    foreach ($form->fields as $key => $value) {
        db_query("INSERT INTO {cc_config} (name, value)\n              VALUES (:name,:value)\n              ON DUPLICATE KEY UPDATE value=:value", array(":name" => $key, ":value" => $value));
    }
    // TODO: test if max_uploadfile_size_kb is bigger then allowed in php.ini
    loadDBConfig();
}