/**
  * get master data
  * @see CTModuleInterface::getMasterData()
  *
  * @return array
  */
 public function getMasterData()
 {
     global $user, $base_url, $files_dir, $config;
     $res = churchdb_getMasterDataTables();
     $res["feldtyp"] = churchcore_getTableData("cdb_feldtyp");
     $res["fields"] = getAllFields();
     $res["groups"] = getAllGroups();
     $res["tags"] = getAllTags();
     $res["FUNachfolgeDomains"] = array("0" => array("id" => "0", "bezeichnung" => "Kein"), "1" => array("id" => "1", "bezeichnung" => $res["fields"]["f_group"]["fields"]["gruppentyp_id"]["text"]), "2" => array("id" => "2", "bezeichnung" => $res["fields"]["f_group"]["fields"]["distrikt_id"]["text"]), "3" => array("id" => "3", "bezeichnung" => t("group")));
     $res["groupMemberTypes"] = getGroupMemberTypes();
     $res["groupFilterTypes"] = churchdb_getGroupFilterTypes();
     // master data information for maintain masterdata and statistics
     if (user_access("edit masterdata", "churchdb") || user_access("view statistics", "churchdb")) {
         $res["masterDataTables"] = churchdb_getMasterDataTablenames();
     }
     $res["user_pid"] = $user->id;
     $res["userid"] = $user->vorname . " " . $user->cmsuserid . " [" . $user->id . "]";
     $res["auth"] = churchdb_getAuthForAjax();
     $res["site_name"] = getConf('site_name');
     $res["modulespath"] = churchdb_getModulesPath();
     $res["files_url"] = $base_url . $files_dir;
     $res["modulename"] = "churchdb";
     $res["max_uploadfile_size_kb"] = getConf('max_uploadfile_size_kb');
     $res["adminemail"] = getConf('site_mail', '');
     $res["max_exporter"] = getConf('churchdb_maxexporter', '150');
     $res["groupnotchoosable"] = getConf('churchdb_groupnotchoosable', 30);
     $res["home_lat"] = getConf('churchdb_home_lat', '53.568537');
     $res["home_lng"] = getConf('churchdb_home_lng', '10.03656');
     $res["settings"] = churchdb_getUserSettings($user->id);
     $res["last_log_id"] = churchdb_getLastLogId();
     $res["mailchimp"] = getConf('churchdb_mailchimp_apikey') != "";
     $res["views"] = array("ArchiveView" => array("filename" => "cdb_archiveview"), "MapView" => array("filename" => "cdb_mapview"), "StatisticView" => array("filename" => "cdb_statisticview"), "SettingsView" => array("filename" => "cdb_settingsview"), "MaintainView" => array("filename" => "cdb_maintainview"), "WeekView" => array("filename" => "../churchresource/cr_weekview"));
     if (user_access("administer persons", "churchcore")) {
         $res["auth_table"] = churchdb_getAuthTable();
     }
     if (isset($res["auth"]["edit newsletter"])) {
         $nl = churchdb_getTableData("cdb_newsletter");
         $newsletter = array();
         foreach ($res["auth"]["edit newsletter"] as $n) {
             $newsletter = $nl[$n];
         }
         $res["newsletter"] = $newsletter;
     }
     return $res;
 }
Exemplo n.º 2
0
function ShowUser()
{
    $dataAll = getAllFields();
    foreach ($dataAll as $user) {
        echo '<tr>';
        echo '<td>' . $user['Nom'] . '</td>';
        echo '<td>' . $user['Prenom'] . '</td>';
        echo '<td>' . $user['Email'] . '</td>';
        echo '<td><a href="users.php?id=' . $user['ID'] . '">Details</a></td>';
        //else{
        if (isset($_SESSION['userlogin']) && $_SESSION['userlogin'] == $user['Pseudo']) {
            echo '<td><a href="index.php?id=' . $user['ID'] . '" name="modifLink">Modifier</a></td>';
            echo '<td><a href="deco.php" name="deleteUser">Supprimer</a></td>';
        } else {
            foreach ($dataAll as $user) {
                if (isset($_SESSION['userlogin']) && $_SESSION['userlogin'] == $user['Pseudo'] && $user['estAdmin']) {
                    echo '<td><a href="index.php?id=' . $user['ID'] . '" name="modifLink">Modifier</a></td>';
                    echo '<td><a href="deco.php" name="deleteUser">Supprimer</a></td>';
                }
            }
            echo '</tr>';
        }
    }
}
Exemplo n.º 3
0
					</script>';
        } else {
            echo '<script language="JavaScript">
						alert("' . $lang['L_PRIMARYKEY_NOTFOUND'] . ': ' . $_GET['killPrimaryKey'] . '");
					</script>';
        }
    } else {
        echo '<script language="JavaScript">
					alert("' . $lang['L_PRIMARYKEY_NOTFOUND'] . ': ' . $_GET['killPrimaryKey'] . '");
				</script>';
    }
}
//Primärschlüssel löschen ende
//Neue Primärschlüssel setzen
if (isset($_POST['setNewPrimaryKeys'])) {
    $fields = getAllFields($databases['Name'][$dbid], $_GET['tablename']);
    $newKeysArray = array();
    foreach ($fields as $index => $field) {
        if (isset($_POST["setNewPrimKey" . $index]) && $_POST["setNewPrimKey" . $index] != "") {
            $newKeysArray[] = $_POST["setNewPrimKey" . $index];
        }
    }
    //doppelte Elemente entfernen
    $newKeysArray = array_unique($newKeysArray);
    $res = setNewPrimaryKeys($databases['Name'][$dbid], $_GET['tablename'], $newKeysArray);
    if ($res) {
        echo '<script language="JavaScript">
					alert("' . $lang['L_PRIMARYKEYS_CHANGED'] . '");
				</script>';
    } else {
        echo '<script language="JavaScript">
Exemplo n.º 4
0
 function replacePQFieldsWithViewHTML($content, $page, $renderedinadminarea)
 {
     $allfields = getAllFields($content);
     foreach ($allfields as $pqfield) {
         $field = getField($pqfield, $page);
         if (!$field->loaded()) {
             // Create field
             $fieldtype = pq($pqfield)->attr("fieldtype");
             // Determine whether the field should be attached to the page or to the 'site' (i.e. page-independent)
             if (pq($pqfield)->attr("type") == "field") {
                 $ref = $page;
             } else {
                 $ref = new siteFieldObject();
             }
             $field = Wi3::inst()->model->factory("site_field")->setref($ref)->set("type", $fieldtype);
             // Store name, if present
             $fieldname = pq($pqfield)->attr("fieldname");
             if ($fieldname) {
                 $field->set("name", $fieldname);
             }
             // This should not happen... Log it!
             if (empty($field->type)) {
                 // TODO: log
                 pq($pqfield)->replaceWith("Could not be loaded");
                 continue;
             }
             /*
                                         var_dump($field);
                                         var_dump(pq($pqfield)->attr("type"));
                                         var_dump(pq($pqfield)->attr("name"));
                                         var_dump(pq($pqfield)->parent()->html());
                                         exit;*/
             $field->create();
         }
         if ($field->loaded()) {
             // Get set style
             $style = pq($pqfield)->attr("style");
             $field->options["style"] = $style;
             // Get style options
             $stylearray = array();
             $stylearray["float"] = pq($pqfield)->attr("style_float");
             $stylearray["padding"] = pq($pqfield)->attr("style_padding");
             $stylearray["width"] = pq($pqfield)->attr("style_width");
             // Only set an explicit display block if no display is found in '$style'
             if (strpos($style, "display:") === false) {
                 $stylearray["display"] = "block";
             }
             $field->options["stylearray"] = $stylearray;
             // Render the field, in which the field can also change the style options
             $fieldhtml = $field->render($renderedinadminarea, $pqfield);
             // The field can override these options, if it wants
             $style = $field->options["style"];
             $stylearray = $field->options["stylearray"];
             // Once the field is rendered, it is known whether it wants to be an inline element, or a block element
             // Use float and padding only if element is not inline
             if (strpos($style, "display:inline") !== false || isset($stylearray["display"]) && $stylearray["display"] == "inline") {
                 unset($stylearray["float"]);
                 unset($stylearray["padding"]);
             }
             // Calculate total style
             $totalstyle = $style;
             foreach ($stylearray as $name => $val) {
                 if (!empty($val)) {
                     $totalstyle .= "; " . $name . ":" . $val;
                 }
             }
             $totalstyle .= "; position: relative;";
             // Replace the <cms> part with a render of the field
             $fieldedithtml = "<div type='field' fieldid='" . $field->id . "' style='" . $totalstyle . "' contenteditable='false'>" . $fieldhtml . "</div>";
             pq($pqfield)->replaceWith($fieldedithtml);
         }
     }
     // Return how many fields were replaced
     return count($allfields);
 }
/**
 * 
 * @param unknown $params
 * @throws CTFail
 */
function f_functions($params)
{
    $function = $params["func"];
    $fields = getAllFields("intern_code='{$function}'");
    // Prüfe, ob eine E_Mail-Adresse gesetz werden soll die es schon gibt ohne Schreibrechte.
    // Das soll verhindert werden, denn sonst kann sich jemand die E-Mail eines Admins geben...
    if (isset($params["email"]) && !user_access("write access", "churchdb")) {
        // Check, if the email address has changed
        $db = db_query("SELECT * FROM {cdb_person} p WHERE id=:id", array(":id" => $params["id"]))->fetch();
        if ($db->email != $params["email"]) {
            // Check, if another user has this email
            $db = db_query("SELECT * FROM {cdb_person} p WHERE email=:email AND id!=:id", array(":email" => $params["email"], ":id" => $params["id"]))->fetch();
            if ($db != false) {
                throw new CTFail("Die E-Mail-Adresse ist schon vergeben. Um eine vergebene E-Mail-Adresse zu setzen werden mehr Rechte gebraucht.");
            }
        }
    }
    if ($function == "f_group") {
        saveGeocodeGruppe($params["id"], "", "");
    }
    foreach ($fields["fields"] as $key => $value) {
        if (isset($params[$key])) {
            $arr[$key] = $params[$key];
        }
    }
    // Wenn die letzteaenderung mit �bergeben wird (z.B. bei Sync mit externen Tools)
    // Soll das hier mit gesetzt werden
    if (isset($params['letzteaenderung'])) {
        $arr['letzteaenderung'] = $params['letzteaenderung'];
    }
    $oldarr = saveDataArray($fields, $params["id"], $arr);
    if (is_string($oldarr)) {
        $res = $oldarr;
    } else {
        $txt = churchcore_getFieldChanges($fields["fields"], $oldarr, $arr);
        if ($txt) {
            if ($function == "f_group") {
                $txt = t("group") . ": " . $arr["bezeichnung"] . "\n" . $txt;
            } else {
                $details = churchdb_getPersonDetails($params["id"]);
                //var_dump($details);
                //        $txt = t("person").": ". $details->vorname. " ". $details->name. " (". $params["id"]. ")\n". $txt;
            }
        }
        sendFieldNotifications($function, $txt);
        if ($txt) {
            cdb_log("{$function} - " . $txt, 2, $params["id"], $function == "f_group" ? CDB_LOG_GROUP : CDB_LOG_PERSON, 1);
        }
    }
}
Exemplo n.º 6
0
/**
 *
 * @param unknown $params
 * @throws CTFail
 */
function f_functions($params)
{
    $function = $params["func"];
    $fields = getAllFields("intern_code = '{$function}'");
    // Check if someone try to set an existing email, but have no administer persons
    // otherwise someone could use the email of an admin...
    if (isset($params["email"]) && !user_access("administer persons", "churchcore")) {
        // Check, if the email address has changed
        $db = db_query("SELECT id, email FROM {cdb_person} p\n                    WHERE id=:id", array(":id" => $params["id"]))->fetch();
        if ($db->email != $params["email"]) {
            // Check if other user have more permissions than this one, than don't allow to set email
            $newUserPerms = getUserAuthorization($params["id"]);
            $db = db_query("SELECT id FROM {cdb_person} p\n                    WHERE email=:email", array(":email" => $params["email"]));
            $morePermissions = false;
            foreach ($db as $p) {
                $otherUserPerms = getUserAuthorization($p->id);
                if (hasMorePerms($newUserPerms, $otherUserPerms)) {
                    $morePermissions = true;
                }
            }
            if ($morePermissions) {
                throw new CTFail(t('email.already.used.you.need.more.rights.to.change.this'));
            }
        }
    }
    if ($function == "f_group") {
        saveGeocodeGruppe($params["id"], "", "");
    }
    $arr = array();
    foreach ($fields["fields"] as $key => $value) {
        if (isset($params[$key])) {
            $arr[$key] = $params[$key];
        }
    }
    // Wenn die letzteaenderung mit �bergeben wird (z.B. bei Sync mit externen Tools)
    // Soll das hier mit gesetzt werden
    if (isset($params['letzteaenderung'])) {
        $arr['letzteaenderung'] = $params['letzteaenderung'];
    }
    $oldarr = saveDataArray($fields, $params["id"], $arr);
    if (is_string($oldarr)) {
        $res = $oldarr;
    } else {
        $txt = churchcore_getFieldChanges($fields["fields"], $oldarr, $arr);
        if ($txt) {
            if ($function == "f_group") {
                $txt = t("group") . ": " . $arr["bezeichnung"] . "\n" . $txt;
            } else {
                $details = churchdb_getPersonDetails($params["id"]);
                //var_dump($details);
                //        $txt = t("person").": ". $details->vorname. " ". $details->name. " (". $params["id"]. ")\n". $txt;
            }
        }
        sendFieldNotifications($function, $txt);
        if ($txt) {
            cdb_log("{$function} - " . $txt, 2, $params["id"], $function == "f_group" ? CDB_LOG_GROUP : CDB_LOG_PERSON, 1);
        }
    }
}