Ejemplo n.º 1
0
/**
 * Outputs the form for editing existing mandant
 */
function edit_mandants()
{
    View::loadScripts();
    if (isset($_GET['order'])) {
        $orderAttribute = mysql_real_escape_string($_GET['order']);
    } else {
        $orderAttribute = "mandantID";
    }
    $mandants = EventDatabaseManager::getAllMandants($orderAttribute);
    View::outputAllMandants('edit_mandants', $mandants);
    View::linkToAddMandant();
    if (isset($_GET['mandantID']) && is_numeric($_GET['mandantID'])) {
        $mandant = EventDatabaseManager::getMandant($_GET['mandantID']);
        $locations = EventDatabaseManager::getAllLocations();
        $mandantLocations = EventDatabaseManager::getMandantLocations($_GET['mandantID']);
        View::mandantFormOutput($mandant['mandantID'], $mandant['company'], $locations, $mandantLocations);
    } else {
        if (isset($_GET['mandantID'])) {
            echo MANDANT_ID_INCORRECT_MESSAGE;
        }
    }
}
 /**
  * Adds a location available for mandant
  * Returns TRUE if location has been added, FALSE if there has been an error, or if the location is already available to mandant
  * 
  * @global wpdb $wpdb
  * @param int $mandantID
  * @param int $locationID
  * @return boolean
  */
 public static function addLocationToMandant($mandantID, $locationID)
 {
     global $wpdb;
     $locations = EventDatabaseManager::getMandantLocations($mandantID);
     if (isset($locations[$locationID])) {
         return false;
     }
     $query = "INSERT INTO datr_Mandant_has_Locations (mandantID, locationID) VALUES ({$mandantID}, {$locationID})";
     return $wpdb->query($query);
 }
Ejemplo n.º 3
0
function save_new_fields($user_id)
{
    if (!current_user_can('edit_user', $user_id)) {
        return false;
    }
    update_user_meta($user_id, 'datr_plugin_language', $_POST['datr_language']);
    if (!current_user_can('manage_options')) {
        return false;
    }
    $topics = EventDatabaseManager::getAllTopics();
    foreach ($topics as $id => $title) {
        if (isset($_POST['user_has_topic_' . $id])) {
            $topicParams = array();
            foreach (EventDatabaseManager::$userHasTopicsParams as $param) {
                $topicParams[$param] = $_POST[$param . '_' . $id];
            }
            EventDatabaseManager::addOrUpdateAssignedTopic($user_id, $id, $topicParams);
        } else {
            EventDatabaseManager::deleteAssignedTopic($user_id, $id);
        }
    }
    $locations = EventDatabaseManager::getMandantLocations(get_user_meta($user_id, 'datr_mandantID', true));
    foreach ($locations as $id => $locationName) {
        if (isset($_POST['location_' . $id])) {
            EventDatabaseManager::addLocationToUser($user_id, $id);
        } else {
            EventDatabaseManager::removeLocationFromUser($user_id, $id);
        }
    }
    update_user_meta($user_id, 'datr_gender', $_POST['datr_gender']);
    update_user_meta($user_id, 'datr_title', $_POST['datr_title']);
    update_user_meta($user_id, 'datr_mandantID', $_POST['datr_mandantID']);
    update_user_meta($user_id, 'datr_department', $_POST['datr_department']);
}