Пример #1
0
 /**
  * Fetch institutes for course sets.
  *
  * @param Array $filter filter settings, e.g. a special subset of allowed
  * admission rules
  *
  * @return Array Found institutes.
  */
 static function getInstitutes($filter = array())
 {
     global $perm, $user;
     $parameters = array(1);
     $query = "SELECT COUNT(DISTINCT ci.set_id) FROM courseset_institute ci\n        LEFT JOIN coursesets c ON c.set_id = ci.set_id\n        LEFT JOIN courseset_rule cr ON c.set_id = cr.set_id\n        LEFT JOIN seminar_courseset sc ON c.set_id = sc.set_id\n        LEFT JOIN seminare s ON s.seminar_id = sc.seminar_id\n        WHERE ci.institute_id = ?";
     if ($filter['course_set_name']) {
         $query .= " AND c.name LIKE ?";
         $parameters[] = $filter['course_set_name'] . '%';
     }
     if (is_array($filter['rule_types']) && count($filter['rule_types'])) {
         $query .= " AND cr.type IN (?)";
         $parameters[] = $filter['rule_types'];
     }
     if ($filter['semester_id']) {
         $query .= " AND s.start_time = ?";
         $parameters[] = Semester::find($filter['semester_id'])->beginn;
     }
     $cs_count_statement = DBManager::get()->prepare($query);
     $query = str_replace('ci.institute_id', '1', $query);
     $cs_count_all_statement = DBManager::get()->prepare($query);
     if ($perm->have_perm('root')) {
         $cs_count_all_statement->execute($parameters);
         $num_sets = $cs_count_all_statement->fetchColumn();
         $my_inst['all'] = array('name' => _('alle'), 'num_sets' => $num_sets);
         $top_insts = Institute::findBySQL('Institut_id = fakultaets_id ORDER BY Name');
     } else {
         $top_insts = Institute::findMany(User::find($user->id)->institute_memberships->findBy('inst_perms', words('admin dozent'))->pluck('institut_id'), 'ORDER BY institut_id=fakultaets_id,name');
     }
     foreach ($top_insts as $inst) {
         $my_inst[$inst->id] = $inst->toArray('name is_fak');
         $parameters[0] = $inst->id;
         $cs_count_statement->execute($parameters);
         $my_inst[$inst->id]['num_sets'] = $cs_count_statement->fetchColumn();
         if ($inst->is_fak && ($perm->have_perm('root') || $inst->members->findBy('user_id', $user->id)->val('inst_perms') == 'admin')) {
             $alle = $inst->sub_institutes;
             if (count($alle)) {
                 $my_inst[$inst->id . '_all'] = array('name' => sprintf(_('[Alle unter %s]'), $inst->name), 'is_fak' => 'all');
                 $num_inst = 0;
                 $num_sets_alle = $my_inst[$inst->id]['num_sets'];
                 foreach ($alle as $institute) {
                     $num_inst += 1;
                     $my_inst[$institute->id] = $institute->toArray('name is_fak');
                     $parameters[0] = $institute->id;
                     $cs_count_statement->execute($parameters);
                     $my_inst[$institute->id]['num_sets'] = $cs_count_statement->fetchColumn();
                     $num_sets_alle += $my_inst[$institute->id]['num_sets'];
                 }
                 $my_inst[$inst->id . '_all']['num_inst'] = $num_inst;
                 $my_inst[$inst->id . '_all']['num_sets'] = $num_sets_alle;
             }
         }
     }
     return $my_inst;
 }
Пример #2
0
 /**
  * Finds all institutes by given search string. Searches for the name of
  * existing or already deleted institutes.
  * 
  * @param type $needle The needle to search for.
  * @return array
  */
 public static function searchInstitute($needle)
 {
     $result = array();
     $institutes = Institute::findBySQL("name LIKE CONCAT('%', ?, '%')", array($needle));
     foreach ($institutes as $institute) {
         $result[] = array($institute->getId(), my_substr($institute->name, 0, 28));
     }
     // search for deleted institutes
     // Name of deleted institute is part of info field,
     // old id (still in DB) is in affected column
     $log_action_delete_institute = SimpleORMapCollection::createFromArray(LogAction::findByName('INST_DEL'))->first();
     $log_events_delete_institute = LogEvent::findBySQL("action_id = ? AND info LIKE CONCAT('%', ?, '%')", array($log_action_delete_institute->getId(), $needle));
     foreach ($log_events_delete_institute as $log_event) {
         $title = sprintf('%s (%s)', $log_event->info, _('gelöscht'));
         $result[] = array($log_event->affected_range_id, $title);
     }
     return $result;
 }
Пример #3
0
        <br/>
        <input type="radio" name="activated" value="inst" onclick="STUDIP.Admission.checkRuleActivation('rule_activation_form')"<?php 
echo $atInst ? ' checked="checked"' : '';
?>
/><?php 
echo _('an ausgewählten Einrichtungen');
?>
    </div>
    <br/>
    <div id="institutes_activation"<?php 
echo $globally ? ' style="display:none"' : '';
?>
>
        <ul>
        <?php 
foreach (Institute::findBySQL("`fakultaets_id`=`Institut_id`") as $fak) {
    ?>
            <li id="<?php 
    echo $fak->Institut_id;
    ?>
">
                <input type="checkbox" name="institutes[]" value="<?php 
    echo $fak->Institut_id;
    ?>
"<?php 
    echo $activated[$fak->Institut_id] ? ' checked="checked"' : '';
    ?>
/>
                <a href=""><?php 
    echo htmlReady($fak->name);
    ?>
Пример #4
0
?>
</option>
                                       <?
                                    }
                                }
                            }
                           ?>
                           </select>
                           <br>
                           <select name="tools_requests_faculty_choose" onChange="document.tools_requests_form.submit()">
                           <option value=""><?php 
echo _("alle Veranstaltungen");
?>
</option>
                           <?
                           foreach (Institute::findBySQL("fakultaets_id=Institut_id ORDER BY Name ASC") as $faculty) {
                               ?>
                               <option <?php 
echo $display_faculty == $faculty->id ? 'selected' : '';
?>
 value="<?php 
echo $faculty->id;
?>
"><?php 
echo htmlReady($faculty->name);
?>
</option>
                               <?
                           }
                           ?>
                           </select>
Пример #5
0
 /**
  * show institute basicdata page
  *
  * @param mixed $i_id Optional institute id 
  * @throws AccessDeniedException
  */
 public function index_action($i_id = false)
 {
     PageLayout::setTitle(_('Verwaltung der Grunddaten'));
     Navigation::activateItem('/admin/institute/details');
     //get ID from an open Institut
     $i_view = $i_id ?: Request::option('i_view', $GLOBALS['SessSemName'][1]);
     if (!$i_view) {
         require_once 'lib/admin_search.inc.php';
         // This search just died a little inside, so it should be safe to
         // continue here but we nevertheless return just to be sure
         return;
     } elseif ($i_view === 'new') {
         closeObject();
     }
     //  allow only inst-admin and root to view / edit
     if ($i_view && !$GLOBALS['perm']->have_studip_perm('admin', $i_view) && $i_view !== 'new') {
         throw new AccessDeniedException();
     }
     //Change header_line if open object
     $header_line = getHeaderLine($i_view);
     if ($header_line) {
         PageLayout::setTitle($header_line . ' - ' . PageLayout::getTitle());
     }
     if (Request::get('i_trykill')) {
         $message = _('Sind Sie sicher, dass Sie diese Einrichtung löschen wollen?');
         $post['i_kill'] = 1;
         $post['studipticket'] = get_ticket();
         $this->question = createQuestion2($message, $post, array(), $this->url_for('institute/basicdata/delete/' . $i_view));
     }
     $lockrule = LockRules::getObjectRule($i_view);
     if ($lockrule->description && LockRules::CheckLockRulePermission($i_view, $lockrule['permission'])) {
         PageLayout::postMessage(MessageBox::info(formatLinks($lockrule->description)));
     }
     // Load institute data
     $institute = new Institute($i_view === 'new' ? null : $i_view);
     //add the free administrable datafields
     $datafields = array();
     $localEntries = DataFieldEntry::getDataFieldEntries($institute->id, 'inst');
     if ($localEntries) {
         $invalidEntries = $this->flash['invalid_entries'] ?: array();
         foreach ($localEntries as $entry) {
             if (!$entry->isVisible()) {
                 continue;
             }
             $color = '#000000';
             if (in_array($entry->getId(), $invalidEntries)) {
                 $color = '#ff0000';
             }
             $datafields[] = array('color' => $color, 'title' => $entry->getName(), 'value' => $GLOBALS['perm']->have_perm($entry->isEditable()) && !LockRules::Check($institute['Institut_id'], $entry->getId()) ? $entry->getHTML('datafields') : $entry->getDisplayValue());
         }
     }
     // Read faculties if neccessary
     if (count($institute->sub_institutes) === 0) {
         if ($GLOBALS['perm']->have_perm('root')) {
             $this->faculties = Institute::findBySQL('Institut_id = fakultaets_id ORDER BY Name ASC', array($i_view));
         } else {
             $temp = User::find($GLOBALS['user']->id)->institute_memberships->findBy('inst_perms', 'admin')->pluck('institute');
             $institutes = SimpleORMapCollection::createFromArray($temp);
             $faculties = $institutes->filter(function ($institute) {
                 return $institute->is_fak;
             });
             $this->faculties = $faculties;
         }
     }
     // Indicates whether the current user is allowed to delete the institute
     $this->may_delete = $i_view !== 'new' && !(count($institute->home_courses) || count($institute->sub_institutes)) && ($GLOBALS['perm']->have_perm('root') || $GLOBALS['perm']->is_fak_admin() && get_config('INST_FAK_ADMIN_PERMS') == 'all');
     if (!$this->may_delete) {
         //Set infotext for disabled delete-button
         $reason_txt = _('Löschen nicht möglich.');
         if (count($institute->home_courses) > 0) {
             $reason_txt .= ' ';
             $reason_txt .= sprintf(ngettext('Es ist eine Veranstaltung zugeordnet.', 'Es sind %u Veranstaltungen zugeordnet.', count($institute->home_courses)), count($institute->home_courses));
         }
         if (count($institute->sub_institutes) > 0) {
             $reason_txt .= ' ';
             $reason_txt .= sprintf(ngettext('Es ist eine Einrichtung zugeordnet.', 'Es sind %u Einrichtungen zugeordnet.', count($institute->sub_institutes)), count($institute->sub_institutes));
         }
     }
     // Indicates whether the current user is allowed to change the faculty
     $this->may_edit_faculty = $GLOBALS['perm']->is_fak_admin() && !LockRules::Check($institute['Institut_id'], 'fakultaets_id') && ($GLOBALS['perm']->have_studip_perm('admin', $institute['fakultaets_id']) || $i_view === 'new');
     // Prepare template
     $this->institute = $institute;
     $this->i_view = $i_view;
     $this->datafields = $datafields;
     $this->reason_txt = $reason_txt;
 }