Exemple #1
0
 /**
  * Trägt den Benutzer in den Eingestellten veranstaltungen automatisch ein.
  * @param type $user_id
  * @param type $status Wenn Status nicht angegeben wird, wird der Status des Users aus user_id genommen
  * @return array 'added' Namen der Seminare in die der User eingetragen wurde
  *         array 'removed' Namen der Seminare aus denen der User ausgetragen wurde
  */
 public function saveUser($user_id, $status = FALSE)
 {
     $domains = array();
     if (!$status) {
         $status = get_global_perm($user_id);
     }
     foreach (UserDomain::getUserDomainsForUser($user_id) as $d) {
         $domains[] = $d->getID();
         //Domains des Users
     }
     if (count($domains) == 0) {
         $domains[] = 'keine';
     }
     $settings = array();
     $all_seminare = array();
     foreach ($domains as $domain) {
         $key = $domain . '.' . $status;
         if (is_array($this->settings[$key])) {
             $id = key($this->settings[$key]);
             foreach ($this->settings[$key] as $id => $value) {
                 $settings[$id] = $value;
             }
         }
         foreach ($this->settings as $key) {
             foreach ($key as $id => $sem) {
                 $all_seminare[$id] = $sem;
             }
         }
     }
     $seminare = array();
     $seminare_tutor_dozent = array();
     foreach ($this->getUserSeminars($user_id, array_keys($all_seminare)) as $sem) {
         $seminare[$sem['Seminar_id']] = $sem;
         if (in_array($sem['status'], array('tutor', 'dozent'))) {
             $seminare_tutor_dozent[$sem['Seminar_id']] = $sem;
         }
     }
     $toAdd = array_diff_key($settings, $seminare);
     $toRemove = array_diff_key($all_seminare, $toAdd, $settings, $seminare_tutor_dozent);
     $added = array();
     $removed = array();
     foreach ($toAdd as $id => $seminar) {
         if ($this->addUser($user_id, $seminar)) {
             $added[] = $seminar['name'];
         }
     }
     foreach ($toRemove as $id => $seminar) {
         if ($this->removeUser($user_id, $seminar)) {
             $removed[] = $seminar['name'];
         }
     }
     return array('added' => $added, 'removed' => $removed);
 }
Exemple #2
0
 function verify($user_id, $other_id)
 {
     if ($other_id === 'nobody') {
         return false;
     }
     $user_domains = UserDomain::getUserDomainsForUser($user_id);
     $owner_domains = UserDomain::getUserDomainsForUser($other_id);
     if (count($user_domains) || count($owner_domains)) {
         return count(array_intersect($user_domains, $owner_domains)) > 0;
     } else {
         return true;
     }
 }
 public function afterUpdate(SimpleORMap $object, $line)
 {
     $old_domains = array_map(function ($domain) {
         return $domain->getID();
     }, $this->old_domains);
     $new_domains = UserDomain::getUserDomainsForUser($object->getId());
     foreach ($new_domains as $domain_id) {
         if (!in_array($domain_id, $old_domains)) {
             if ($domain_id === "alumni") {
                 if (count($new_domains) == 1) {
                     $statement = DBManager::get()->prepare("\n                            SELECT seminar_user.Seminar_id \n                            FROM seminar_user\n                                LEFT JOIN seminar_userdomain ON (seminar_user.Seminar_id = seminar_userdomain.Seminar_id)\n                            WHERE seminar_user.user_id = :user_id\n                                AND seminar_user.Seminar_id NOT IN (SELECT seminar_id FROM seminar_userdomain WHERE userdomain_id = 'alumni')\n                        ");
                     $statement->execute(array('user_id' => $object->getId()));
                     foreach ($statement->fetchAll(PDO::FETCH_COLUMN, 0) as $seminar_id) {
                         $seminar = new Seminar($seminar_id);
                         $seminar->deleteMember($object->getId());
                     }
                 }
                 $datafield = Datafield::findOneBySQL("name = 'Ich will weiterhin als Alumni in Stud.IP geführt werden' AND object_type = 'user'");
                 $user_wants_to_stay = DatafieldEntry::findOneBySQL("datafield_id = ? AND range_id = ?", array($datafield->getId(), $object->getId()));
                 if ($user_wants_to_stay['content']) {
                     //In Veranstaltung ALUMNI die Statusgruppe anlegen:
                     $datafield = Datafield::findOneBySQL("name = 'Alumni' AND object_type = 'user'");
                     $entry = DatafieldEntry::findOneBySQL("datafield_id = ? AND range_id = ?", array($datafield->getId(), $object->getId()));
                     $course = Course::findOneByName("ALUMNI");
                     $gruppenname = $entry ? $entry['content'] : null;
                     if ($course && $gruppenname) {
                         $statusgruppe = Statusgruppen::findOneBySQL("name = ? range_id = ?", array($gruppenname, $course->getId()));
                         if (!$statusgruppe) {
                             $statusgruppe = new Statusgruppen();
                             $statusgruppe['name'] = $gruppenname;
                             $statusgruppe['range_id'] = $course->getId();
                             $statusgruppe->store();
                         }
                         if (!$statusgruppe->isMember($object->getId())) {
                             $statusgruppe->addUser($object->getId());
                         }
                     }
                 } else {
                     $object->delete();
                     $deleted = true;
                 }
             }
         }
     }
 }
Exemple #4
0
/**
 * Checks whether an element of a user homepage is visible for another user.
 * We do not give an element name and look up its visibility setting in the
 * database, because that would generate many database requests for a single
 * user homepage. Instead, the homepage itself loads all element visibilities
 * and we only need to check if the given element visibility allows showing it
 * to the visiting user. We need not check for not hideable fields here,
 * because that is already done when loading the element visibilities.
 *
 * @param string $user_id ID of the user who wants to see the element
 * @param string $owner_id ID of the homepage owner
 * @param int $element_visibility visibility level of the element, one of
 * the constants VISIBILITY_ME, VISIBILITY_BUDDIES, VISIBILITY_DOMAIN,
 * VISIBILITY_STUDIP, VISIBILITY_EXTERN
 * @return boolean Is the element visible?
 */
function is_element_visible_for_user($user_id, $owner_id, $element_visibility) {
    $is_visible = false;
    if ($user_id == $owner_id) {
        $is_visible = true;
    // Deputies with homepage editing rights see the same as the owner
    } else if (get_config('DEPUTIES_ENABLE') && get_config('DEPUTIES_DEFAULTENTRY_ENABLE') && get_config('DEPUTIES_EDIT_ABOUT_ENABLE') && isDeputy($user_id, $owner_id, true)) {
        $is_visible = true;
    } else {
        // No element visibility given (user has not configured this element yet)
        // Set default visibility as element visibility
        if (!$element_visibility) {
            $element_visibility = get_default_homepage_visibility($owner_id);
        }
        // Check if the given element is visible according to its visibility.
        switch ($element_visibility) {
            case VISIBILITY_EXTERN:
                $is_visible = true;
                break;
            case VISIBILITY_STUDIP:
                if ($user_id != "nobody") {
                    $is_visible = true;
                }
                break;
            case VISIBILITY_DOMAIN:
                $user_domains = UserDomain::getUserDomainsForUser($user_id);
                $owner_domains = UserDomain::getUserDomainsForUser($owner_id);
                if ((count($user_domains) === 0 && count($owner_domains) === 0)
                    || array_intersect($user_domains, $owner_domains)) {
                    $is_visible = true;
                }
                break;
            case VISIBILITY_BUDDIES:
                if (Contact::CountBySQL("user_id=? AND owner_id=?", array($user_id, $owner_id))) {
                    $is_visible = true;
                }
                break;
            case VISIBILITY_ME:
                if ($owner_id == $user_id) {
                    $is_visible = true;
                }
                break;
        }
    }
    return $is_visible;
}
Exemple #5
0
 /**
  * Creates a list of online users - optionally including the according
  * contact groups.
  * The created list is an array with four elemens:
  * - "total" is the _number_ of all currently online users.
  * - "buddies" is an _array_ containing the data of all the user's buddies
  *   that are currently online.
  * - "users" is an _array_ containing the data of all users that are
  *   currently online and are not a buddy of the current user and are
  *   either globally visible or visible in the current user's domains.
  * - "others" is the number of all other and accordingly invisible users.
  *
  * @param bool $show_buddy_groups Defines whether the list of buddies
  *                                should include the according contact
  *                                groups or not
  * @return Array List of online users as an array (see above)
  */
 private function getOnlineUsers($show_buddy_groups = false)
 {
     $temp = get_users_online(10, $GLOBALS['user']->cfg->ONLINE_NAME_FORMAT);
     $total = count($temp);
     // Filter invisible users
     $visible = array();
     $my_domains = UserDomain::getUserDomainsForUser($GLOBALS['user']->id);
     foreach ($temp as $username => $user) {
         if ($user['is_visible']) {
             continue;
         }
         $global_visibility = get_global_visibility_by_id($user['user_id']);
         $domains = UserDomain::getUserDomainsForUser($user['user_id']);
         $same_domains = array_intersect($domains, $my_domains);
         if ($global_visibility !== 'yes' || !count($same_domains)) {
             unset($temp[$username]);
         }
     }
     // Split list into buddies and other users
     $buddies = array_filter($temp, function ($user) {
         return $user['is_buddy'];
     });
     $users = array_filter($temp, function ($user) {
         return !$user['is_buddy'];
     });
     if ($show_buddy_groups) {
         // Add groups to buddies
         $buddy_ids = array_map(function ($user) {
             return $user['user_id'];
         }, $buddies);
         $name_format = $GLOBALS['user']->cfg->ONLINE_NAME_FORMAT;
         if (!isset($GLOBALS['_fullname_sql'][$name_format])) {
             $name_format = reset(array_keys($GLOBALS['_fullname_sql']));
         }
         $query = "SELECT user_id, statusgruppen.position, name, statusgruppen.statusgruppe_id\n                      FROM statusgruppen\n                        JOIN statusgruppe_user USING (statusgruppe_id)\n                        JOIN auth_user_md5 USING (user_id)\n                      WHERE range_id = :user_id AND user_id IN (:buddy_ids)\n                      ORDER BY statusgruppen.position ASC";
         $statement = DBManager::get()->prepare($query);
         $statement->bindValue(':user_id', $GLOBALS['user']->id);
         $statement->bindValue(':buddy_ids', $buddy_ids ?: array(''), StudipPDO::PARAM_ARRAY);
         $statement->execute();
         $grouped = $statement->fetchGrouped();
         foreach ($buddies as $username => $buddy) {
             if (isset($grouped[$buddy['user_id']])) {
                 $group = $grouped[$buddy['user_id']];
                 $buddies[$username]['group'] = $group['name'];
                 $buddies[$username]['group_id'] = $group['statusgruppe_id'];
                 $buddies[$username]['group_position'] = $group['position'];
             } else {
                 $buddies[$username]['group'] = _('Kontakte ohne Gruppenzuordnung');
                 $buddies[$username]['group_id'] = 'all';
                 $buddies[$username]['group_position'] = 100000;
             }
         }
         usort($buddies, function ($a, $b) {
             return $a['group_position'] - $b['group_position'] ?: strcmp($a['name'], $b['name']);
         });
     }
     $others = $total - count($buddies) - count($users);
     return compact('buddies', 'users', 'total', 'others');
 }
Exemple #6
0
 /**
  * returns array with information about enrolment to this course for given user_id
  * ['enrolment_allowed'] : true or false
  * ['cause']: keyword to describe the cause
  * ['description'] : readable description of the cause
  *
  * @param string $user_id
  * @return array
  */
 public function getEnrolmentInfo($user_id)
 {
     $info = array();
     $user = User::find($user_id);
     if ($this->read_level == 0 && get_config('ENABLE_FREE_ACCESS') && !$GLOBALS['perm']->get_studip_perm($this->getId(), $user_id)) {
         $info['enrolment_allowed'] = true;
         $info['cause'] = 'free_access';
         $info['description'] = _("Für die Veranstaltung ist keine Anmeldung erforderlich.");
         return $info;
     }
     if (!$user) {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'nobody';
         $info['description'] = _("Sie sind nicht angemeldet.");
         return $info;
     }
     if ($GLOBALS['perm']->have_perm('root', $user_id)) {
         $info['enrolment_allowed'] = true;
         $info['cause'] = 'root';
         $info['description'] = _("Sie dürfen ALLES.");
         return $info;
     }
     if ($GLOBALS['perm']->have_studip_perm('admin', $this->getId(), $user_id)) {
         $info['enrolment_allowed'] = true;
         $info['cause'] = 'courseadmin';
         $info['description'] = _("Sie sind Administrator_in der Veranstaltung.");
         return $info;
     }
     if ($GLOBALS['perm']->have_perm('admin', $user_id)) {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'admin';
         $info['description'] = _("Als Administrator_in können Sie sich nicht für eine Veranstaltung anmelden.");
         return $info;
     }
     //Ist bereits Teilnehmer
     if ($GLOBALS['perm']->have_studip_perm('user', $this->getId(), $user_id)) {
         $info['enrolment_allowed'] = true;
         $info['cause'] = 'member';
         $info['description'] = _("Sie sind für die Veranstaltung angemeldet.");
         return $info;
     }
     $admission_status = $user->admission_applications->findBy('seminar_id', $this->getId())->val('status');
     if ($admission_status == 'accepted') {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'accepted';
         $info['description'] = _("Sie wurden für diese Veranstaltung vorläufig akzeptiert.");
         return $info;
     }
     if ($admission_status == 'awaiting') {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'awaiting';
         $info['description'] = _("Sie stehen auf der Warteliste für diese Veranstaltung.");
         return $info;
     }
     if ($GLOBALS['perm']->get_perm($user_id) == 'user') {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'user';
         $info['description'] = _("Sie haben nicht die erforderliche Berechtigung sich für eine Veranstaltung anzumelden.");
         return $info;
     }
     //falsche Nutzerdomäne
     $same_domain = true;
     $user_domains = UserDomain::getUserDomainsForUser($user_id);
     if (count($user_domains) > 0) {
         $seminar_domains = UserDomain::getUserDomainsForSeminar($this->getId());
         $same_domain = count(array_intersect($seminar_domains, $user_domains)) > 0;
     }
     if (!$same_domain && !$this->isStudygroup()) {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'domain';
         $info['description'] = _("Sie sind nicht in einer zugelassenenen Nutzerdomäne, Sie können sich nicht eintragen!");
         return $info;
     }
     //Teilnehmerverwaltung mit Sperregel belegt
     if (LockRules::Check($this->getId(), 'participants')) {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'locked';
         $lockdata = LockRules::getObjectRule($this->getId());
         $info['description'] = _("In diese Veranstaltung können Sie sich nicht eintragen!") . ($lockdata['description'] ? '<br>' . formatLinks($lockdata['description']) : '');
         return $info;
     }
     //Veranstaltung unsichtbar für aktuellen Nutzer
     if (!$this->visible && !$this->isStudygroup() && !$GLOBALS['perm']->have_perm(get_config('SEM_VISIBILITY_PERM'), $user_id)) {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'invisible';
         $info['description'] = _("Die Veranstaltung ist gesperrt, Sie können sich nicht eintragen!");
         return $info;
     }
     if ($courseset = $this->getCourseSet()) {
         $info['enrolment_allowed'] = true;
         $info['cause'] = 'courseset';
         $info['description'] = _("Die Anmeldung zu dieser Veranstaltung folgt speziellen Regeln. Lesen Sie den Hinweistext.");
         $user_prio = AdmissionPriority::getPrioritiesByUser($courseset->getId(), $user_id);
         if (isset($user_prio[$this->getId()])) {
             $info['description'] .= ' ' . sprintf(_("(Sie stehen auf der Anmeldeliste für die automatische Platzverteilung mit der Priorität %s.)"), $user_prio[$this->getId()]);
         }
         return $info;
     }
     $info['enrolment_allowed'] = true;
     $info['cause'] = 'normal';
     $info['description'] = '';
     return $info;
 }
 /**
  * Imports a line of the table into the Stud.IP database if the check returns no errors.
  * @param array $line : array of fields
  * @return array : array('found' => true|false, 'errors' => "Error message", 'pk' => "primary key")
  */
 public function importLine($line)
 {
     $plugin = $this->getPlugin();
     $classname = $this['import_type'];
     if (!$classname) {
         return array();
     }
     $data = $this->getMappedData($line);
     $pk = $this->getPrimaryKey($data);
     //Last chance to quit:
     $error = $this->checkLine($line, $data, $pk);
     $output = array();
     $object = new $classname($pk);
     if (!$object->isNew()) {
         $output['found'] = true;
         $output['pk'] = $pk;
         foreach ((array) $this['tabledata']['ignoreonupdate'] as $fieldname) {
             unset($data[$fieldname]);
         }
     } else {
         $output['found'] = false;
     }
     foreach ($data as $fieldname => $value) {
         if ($value !== false && in_array($fieldname, $this->getTargetFields())) {
             $object[$fieldname] = $value;
             if ($classname === "User" && $fieldname === "password") {
                 $object[$fieldname] = UserManagement::getPwdHasher()->HashPassword($value);
             }
         }
     }
     if (method_exists($object, "getFullName")) {
         $error['name'] = $output['name'] = $object->getFullName();
     } elseif ($object->isField("name")) {
         $error['name'] = $output['name'] = $object['name'];
     } elseif ($object->isField("title")) {
         $error['name'] = $output['name'] = $object['title'];
     }
     if ($error && $error['errors']) {
         //exit here to have the name of the object in the log
         return $error;
     }
     if ($plugin) {
         $plugin->beforeUpdate($object, $line, $data);
     }
     $object->store();
     $output['pk'] = (array) $object->getId();
     //Dynamic special fields:
     switch ($classname) {
         case "Course":
             //fleximport_dozenten
             foreach ($data['fleximport_dozenten'] as $dozent_id) {
                 $seminar = new Seminar($object->getId());
                 $seminar->addMember($dozent_id, 'dozent');
             }
             //fleximport_related_institutes
             if (!$data['fleximport_related_institutes']) {
                 $data['fleximport_related_institutes'] = array($object['institut_id']);
             } else {
                 if (!in_array($object['institut_id'], $data['fleximport_related_institutes'])) {
                     $data['fleximport_related_institutes'][] = $object['institut_id'];
                 }
             }
             foreach ($data['fleximport_related_institutes'] as $institut_id) {
                 $insert = DBManager::get()->prepare("\n                        INSERT IGNORE INTO seminar_inst\n                        SET seminar_id = :seminar_id,\n                            institut_id = :institut_id\n                    ");
                 $insert->execute(array('seminar_id' => $object->getId(), 'institut_id' => $institut_id));
             }
             if ($this['tabledata']['simplematching']["fleximport_course_userdomains"]['column'] || in_array("fleximport_course_userdomains", $this->fieldsToBeDynamicallyMapped())) {
                 $statement = DBManager::get()->prepare("\n                        SELECT userdomain_id\n                        FROM seminar_userdomains\n                        WHERE seminar_id = ?\n                    ");
                 $statement->execute(array($object->getId()));
                 $olddomains = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
                 foreach (array_diff($data['fleximport_user_inst'], $olddomains) as $to_add) {
                     $domain = new UserDomain($to_add);
                     $domain->addSeminar($object->getId());
                 }
                 foreach (array_diff($olddomains, $data['fleximport_user_inst']) as $to_remove) {
                     $domain = new UserDomain($to_remove);
                     $domain->removeSeminar($object->getId());
                 }
             }
             break;
         case "User":
             if ($this['tabledata']['simplematching']["fleximport_user_inst"]['column'] || in_array("fleximport_user_inst", $this->fieldsToBeDynamicallyMapped())) {
                 if ($object['perms'] !== "root") {
                     foreach ($data['fleximport_user_inst'] as $institut_id) {
                         $member = new InstituteMember(array($object->getId(), $institut_id));
                         $member['inst_perms'] = $object['perms'];
                         $member->store();
                     }
                 }
             }
             if ($this['tabledata']['simplematching']["fleximport_userdomains"]['column'] || in_array("fleximport_userdomains", $this->fieldsToBeDynamicallyMapped())) {
                 $olddomains = UserDomain::getUserDomainsForUser($object->getId());
                 foreach ($olddomains as $olddomain) {
                     if (!in_array($olddomain->getID(), (array) $data['fleximport_userdomains'])) {
                         $olddomain->removeUser($object->getId());
                     }
                 }
                 foreach ($data['fleximport_userdomains'] as $userdomain) {
                     $domain = new UserDomain($userdomain);
                     $domain->addUser($object->getId());
                 }
                 AutoInsert::instance()->saveUser($object->getId());
                 foreach ($data['fleximport_userdomains'] as $domain_id) {
                     if (!in_array($domain_id, $olddomains)) {
                         $welcome = FleximportConfig::get("USERDOMAIN_WELCOME_" . $domain_id);
                         if ($welcome) {
                             foreach ($object->toArray() as $field => $value) {
                                 $welcome = str_replace("{{" . $field . "}}", $value, $welcome);
                             }
                             foreach ($line as $field => $value) {
                                 $welcome = str_replace("{{" . $field . "}}", $value, $welcome);
                             }
                             if (strpos($welcome, "\n") === false) {
                                 $subject = _("Willkommen!");
                             } else {
                                 $subject = strstr($welcome, "\n", true);
                                 $welcome = substr($welcome, strpos($welcome, "\n") + 1);
                             }
                             $messaging = new messaging();
                             $count = $messaging->insert_message($welcome, $object->username, '____%system%____', null, null, null, null, $subject, true, 'normal');
                         }
                     }
                 }
             }
             if ($this['tabledata']['simplematching']["fleximport_expiration_date"]['column'] || in_array("fleximport_expiration_date", $this->fieldsToBeDynamicallyMapped())) {
                 if ($data['fleximport_expiration_date']) {
                     UserConfig::get($object->getId())->store("EXPIRATION_DATE", $data['fleximport_expiration_date']);
                 } else {
                     UserConfig::get($object->getId())->delete("EXPIRATION_DATE");
                 }
             }
             if ($output['found'] === false && $data['fleximport_welcome_message'] !== "none") {
                 $user_language = getUserLanguagePath($object->getId());
                 setTempLanguage(false, $user_language);
                 if ($data['fleximport_welcome_message'] && FleximportConfig::get($data['fleximport_welcome_message'])) {
                     $message = FleximportConfig::get($data['fleximport_welcome_message']);
                     foreach ($data as $field => $value) {
                         $message = str_replace("{{" . $field . "}}", $value, $message);
                     }
                     foreach ($line as $field => $value) {
                         if (!in_array($field, $data)) {
                             $message = str_replace("{{" . $field . "}}", $value, $message);
                         }
                     }
                     if (strpos($message, "\n") === false) {
                         $subject = dgettext($user_language, "Anmeldung Stud.IP-System");
                     } else {
                         $subject = strstr($message, "\n", true);
                         $message = substr($message, strpos($message, "\n") + 1);
                     }
                 } else {
                     $Zeit = date("H:i:s, d.m.Y", time());
                     $this->user_data = array('auth_user_md5.username' => $object['username'], 'auth_user_md5.perms' => $object['perms'], 'auth_user_md5.Vorname' => $object['vorname'], 'auth_user_md5.Nachname' => $object['nachname'], 'auth_user_md5.Email' => $object['email']);
                     $password = $data['password'];
                     //this is the not hashed password in cleartext
                     include "locale/{$user_language}/LC_MAILS/create_mail.inc.php";
                     $message = $mailbody;
                 }
                 if ($message) {
                     $mail = new StudipMail();
                     $mail->addRecipient($object['email'], $object->getFullName());
                     $mail->setSubject($subject);
                     $mail->setBodyText($message);
                     $mail->setBodyHtml(formatReady($message));
                     if (Config::get()->MAILQUEUE_ENABLE) {
                         MailQueueEntry::add($mail);
                     } else {
                         $mail->send();
                     }
                 }
                 restoreLanguage();
             }
             break;
     }
     //Datafields:
     $datafields = array();
     switch ($classname) {
         case "Course":
             $datafields = Datafield::findBySQL("object_type = 'sem'");
             break;
         case "User":
             $datafields = Datafield::findBySQL("object_type = 'user'");
             break;
         case "CourseMember":
             $datafields = Datafield::findBySQL("object_type = 'usersemdata'");
             break;
     }
     foreach ($datafields as $datafield) {
         $fieldname = $datafield['name'];
         if (isset($data[$fieldname])) {
             $entry = new DatafieldEntryModel(array($datafield->getId(), $object->getId(), ""));
             $entry['content'] = $data[$fieldname];
             $entry->store();
         }
     }
     if ($classname === "Course") {
         if ($this['tabledata']['simplematching']["fleximport_studyarea"]['column'] || in_array("fleximport_studyarea", $this->fieldsToBeDynamicallyMapped())) {
             //Studienbereiche:
             $remove = DBManager::get()->prepare("\n                    DELETE FROM seminar_sem_tree\n                    WHERE seminar_id = :seminar_id\n                ");
             $remove->execute(array('seminar_id' => $object->getId()));
             if ($GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][$data['status']]['class']]['bereiche']) {
                 foreach ($data['fleximport_studyarea'] as $sem_tree_id) {
                     $insert = DBManager::get()->prepare("\n                            INSERT IGNORE INTO seminar_sem_tree\n                            SET sem_tree_id = :sem_tree_id,\n                                seminar_id = :seminar_id\n                        ");
                     $insert->execute(array('sem_tree_id' => $sem_tree_id, 'seminar_id' => $object->getId()));
                 }
             }
         }
         if ($this['tabledata']['simplematching']["fleximport_locked"]['column'] || in_array("fleximport_locked", $this->fieldsToBeDynamicallyMapped())) {
             //Lock or unlock course
             if ($data['fleximport_locked']) {
                 CourseSet::addCourseToSet(CourseSet::getGlobalLockedAdmissionSetId(), $object->getId());
             } elseif (in_array($data['fleximport_locked'], array("0", 0)) && $data['fleximport_locked'] !== "") {
                 CourseSet::removeCourseFromSet(CourseSet::getGlobalLockedAdmissionSetId(), $object->getId());
             }
         }
         $folder_exist = DBManager::get()->prepare("\n                SELECT 1 FROM folder WHERE range_id = ?\n            ");
         $folder_exist->execute(array($object->getId()));
         if (!$folder_exist->fetch()) {
             $insert_folder = DBManager::get()->prepare("\n                    INSERT IGNORE INTO folder\n                    SET folder_id = MD5(CONCAT(:seminar_id, 'allgemeine_dateien')),\n                    range_id = :seminar_id,\n                    user_id = :user_id,\n                    name = :name,\n                    description = :description,\n                    mkdate = UNIX_TIMESTAMP(),\n                    chdate = UNIX_TIMESTAMP()\n                ");
             $insert_folder->execute(array('seminar_id' => $object->getId(), 'user_id' => $GLOBALS['user']->id, 'name' => _("Allgemeiner Dateiordner"), 'description' => _("Ablage für allgemeine Ordner und Dokumente der Veranstaltung")));
         }
     }
     if ($plugin && !$object->isNew()) {
         $plugin->afterUpdate($object, $line);
     }
     return $output;
 }
 /**
  * This method sets the user domains for the current user.
  *
  * @access  private
  * @param   User  the user object
  */
 function setUserDomains($user)
 {
     $user_domains = $this->getUserDomains();
     $uid = $user->id;
     if (isset($user_domains)) {
         $old_domains = UserDomain::getUserDomainsForUser($uid);
         foreach ($old_domains as $domain) {
             if (!in_array($domain->getID(), $user_domains)) {
                 $domain->removeUser($uid);
             }
         }
         foreach ($user_domains as $user_domain) {
             $domain = new UserDomain($user_domain);
             $name = $domain->getName();
             if (!isset($name)) {
                 $domain->setName($user_domain);
                 $domain->store();
             }
             if (!in_array($domain, $old_domains)) {
                 $domain->addUser($uid);
             }
         }
     }
 }
Exemple #9
0
 function select_userdomain()
 {
     $user_domains = UserDomain::getUserDomainsForUser($this->auth_user['user_id']);
     $all_domains = UserDomain::getUserDomains();
     $domains = array_diff($all_domains, $user_domains);
     echo '<select name="new_userdomain" id="new_userdomain">' . "\n";
     echo '<option selected value="none">' . _('-- Bitte Nutzerdomäne auswählen --') . '</option>' . "\n";
     foreach ($domains as $domain) {
         printf('<option value="%s">%s</option>' . "\n", $domain->getID(), htmlReady(my_substr($domain->getName(), 0, 50)));
     }
     echo "</select>\n";
 }