Пример #1
0
 /**
  * updates studygroups with respect to the corresponding form data
  *
  * @param string id of a studygroup
  *
  * @return void
  */
 function update_action($id)
 {
     global $perm;
     // if we are permitted to edit the studygroup get some data...
     if ($perm->have_studip_perm('dozent', $id)) {
         $errors = array();
         $admin = $perm->have_studip_perm('admin', $id);
         $founders = StudygroupModel::getFounders($id);
         $sem = new Seminar($id);
         $sem_class = $GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][$sem->status]['class']];
         CSRFProtection::verifyUnsafeRequest();
         if (Request::get('abort_deactivate')) {
             // let's do nothing and go back to the studygroup
             return $this->redirect('course/studygroup/edit/' . $id);
         } else {
             if (Request::get('really_deactivate')) {
                 $modules = Request::optionArray('deactivate_modules');
                 $plugins = Request::optionArray('deactivate_plugins');
                 // really deactive modules
                 // 1. Modules
                 if (is_array($modules)) {
                     $mods = new Modules();
                     $admin_mods = new AdminModules();
                     $bitmask = $sem->modules;
                     foreach ($modules as $key) {
                         $module_name = $sem_class->getSlotModule($key);
                         if ($module_name && ($sem_class->isModuleMandatory($module_name) || !$sem_class->isModuleAllowed($module_name))) {
                             continue;
                         }
                         $mods->clearBit($bitmask, $mods->registered_modules[$key]["id"]);
                         $methodDeactivate = "module" . ucfirst($key) . "Deactivate";
                         if (method_exists($admin_mods, $methodDeactivate)) {
                             $admin_mods->{$methodDeactivate}($sem->id);
                             $studip_module = $sem_class->getModule($key);
                             if (is_a($studip_module, "StandardPlugin")) {
                                 PluginManager::getInstance()->setPluginActivated($studip_module->getPluginId(), $id, false);
                             }
                         }
                     }
                     $sem->modules = $bitmask;
                     $sem->store();
                 }
                 // 2. Plugins
                 if (is_array($plugins)) {
                     $plugin_manager = PluginManager::getInstance();
                     $available_plugins = StudygroupModel::getInstalledPlugins();
                     foreach ($plugins as $class) {
                         $plugin = $plugin_manager->getPlugin($class);
                         // Deaktiviere Plugin
                         if ($available_plugins[$class] && !$sem_class->isModuleMandatory($class) && !$sem_class->isSlotModule($class)) {
                             $plugin_manager->setPluginActivated($plugin->getPluginId(), $id, false);
                         }
                     }
                 }
                 // Success message
                 $this->flash['success'] .= _("Inhaltselement(e) erfolgreich deaktiviert.");
                 return $this->redirect('course/studygroup/edit/' . $id);
             } else {
                 if (Request::submitted('replace_founder')) {
                     // retrieve old founder
                     $old_dozent = current(StudygroupModel::getFounder($id));
                     // remove old founder
                     StudygroupModel::promote_user($old_dozent['uname'], $id, 'tutor');
                     // add new founder
                     $new_founder = Request::option('choose_founder');
                     StudygroupModel::promote_user(get_username($new_founder), $id, 'dozent');
                     //checks
                 } else {
                     // test whether we have a group name...
                     if (!Request::get('groupname')) {
                         $errors[] = _("Bitte Gruppennamen angeben");
                         //... if so, test if this is not taken by another group
                     } else {
                         $query = "SELECT 1 FROM seminare WHERE name = ? AND Seminar_id != ?";
                         $statement = DBManager::get()->prepare($query);
                         $statement->execute(array(Request::get('groupname'), $id));
                         if ($statement->fetchColumn()) {
                             $errors[] = _("Eine Veranstaltung/Studiengruppe mit diesem Namen existiert bereits. Bitte wählen Sie einen anderen Namen");
                         }
                     }
                     if (count($errors)) {
                         $this->flash['errors'] = $errors;
                         $this->flash['edit'] = true;
                         // Everything seems fine, let's update the studygroup
                     } else {
                         $sem->name = Request::get('groupname');
                         // seminar-class quotes itself
                         $sem->description = Request::get('groupdescription');
                         // seminar-class quotes itself
                         $sem->read_level = 1;
                         $sem->write_level = 1;
                         $sem->visible = 1;
                         if (Request::get('groupaccess') == 'all') {
                             $sem->admission_prelim = 0;
                         } else {
                             $sem->admission_prelim = 1;
                             if (Config::get()->STUDYGROUPS_INVISIBLE_ALLOWED && Request::get('groupaccess') == 'invisible') {
                                 $sem->visible = 0;
                             }
                             $sem->admission_prelim_txt = _("Die ModeratorInnen der Studiengruppe können Ihren Aufnahmewunsch bestätigen oder ablehnen. Erst nach Bestätigung erhalten Sie vollen Zugriff auf die Gruppe.");
                         }
                         // get the current bitmask
                         $mods = new Modules();
                         $admin_mods = new AdminModules();
                         $bitmask = $sem->modules;
                         // de-/activate modules
                         $available_modules = StudygroupModel::getInstalledModules();
                         $orig_modules = $mods->getLocalModules($sem->id, "sem");
                         $active_plugins = Request::getArray("groupplugin");
                         $deactivate_modules = array();
                         foreach (array_keys($available_modules) as $key) {
                             $module_name = $sem_class->getSlotModule($key);
                             if (!$module_name || $module_name && ($sem_class->isModuleMandatory($module_name) || !$sem_class->isModuleAllowed($module_name))) {
                                 continue;
                             }
                             if (!$module_name) {
                                 $module_name = $key;
                             }
                             if ($active_plugins[$module_name]) {
                                 // activate modules
                                 $mods->setBit($bitmask, $mods->registered_modules[$key]["id"]);
                                 if (!$orig_modules[$key]) {
                                     $methodActivate = "module" . ucfirst($key) . "Activate";
                                     if (method_exists($admin_mods, $methodActivate)) {
                                         $admin_mods->{$methodActivate}($sem->id);
                                         $studip_module = $sem_class->getModule($key);
                                         if (is_a($studip_module, "StandardPlugin")) {
                                             PluginManager::getInstance()->setPluginActivated($studip_module->getPluginId(), $id, true);
                                         }
                                     }
                                 }
                             } else {
                                 // prepare for deactivation
                                 // (user will have to confirm)
                                 if ($orig_modules[$key]) {
                                     $deactivate_modules[] = $key;
                                 }
                             }
                         }
                         $this->flash['deactivate_modules'] = $deactivate_modules;
                         $sem->modules = $bitmask;
                         $sem->store();
                         // de-/activate plugins
                         $available_plugins = StudygroupModel::getInstalledPlugins();
                         $plugin_manager = PluginManager::getInstance();
                         $deactivate_plugins = array();
                         foreach ($available_plugins as $key => $name) {
                             $plugin = $plugin_manager->getPlugin($key);
                             $plugin_id = $plugin->getPluginId();
                             if ($active_plugins[$key] && $name && $sem_class->isModuleAllowed($key)) {
                                 $plugin_manager->setPluginActivated($plugin_id, $id, true);
                             } else {
                                 if ($plugin_manager->isPluginActivated($plugin_id, $id) && !$sem_class->isSlotModule($key)) {
                                     $deactivate_plugins[$plugin_id] = $key;
                                 }
                             }
                         }
                         $this->flash['deactivate_plugins'] = $deactivate_plugins;
                     }
                 }
             }
         }
     }
     if (!$this->flash['errors'] && !$deactivate_modules && !$deactivate_plugins) {
         // Everything seems fine
         $this->flash['success'] = _("Die Änderungen wurden erfolgreich übernommen.");
     }
     // let's go to the studygroup
     $this->redirect('course/studygroup/edit/' . $id);
 }
Пример #2
0
?>
</a> <?php 
echo $group['visible'] ? '' : "[" . _('versteckt') . "]";
?>
                 </td>
                 <td><?php 
echo strftime('%x', $group['mkdate']);
?>
                </td>
                <td align="center">
                    <?php 
echo StudygroupModel::countMembers($group['Seminar_id']);
?>
                </td>
                <td style="white-space:nowrap;">
                    <? $founders = StudygroupModel::getFounder($group['Seminar_id']);
                    foreach ($founders as $founder) : ?>
                    <?php 
echo Avatar::getAvatar($founder['user_id'])->getImageTag(Avatar::SMALL);
?>
                    <a href="<?php 
echo URLHelper::getlink('dispatch.php/profile?username='******'uname']);
?>
"><?php 
echo htmlready($founder['fullname']);
?>
</a>
                    <br>
                    <? endforeach; ?>
                </td>
                <td align="center">