Exemplo n.º 1
0
 /**
  * Enter description here...
  *
  * @param unknown_type $range_id
  * @param unknown_type $object_type
  * @param unknown_type $object_class_hint
  * @return unknown
  */
 public static function getDataFieldEntries($range_id, $object_type = '', $object_class_hint = '')
 {
     if (!$range_id) {
         return false;
         // we necessarily need a range ID
     }
     $parameters = array();
     if (is_array($range_id)) {
         // rangeID may be an array ("classic" rangeID and second rangeID used for user roles)
         $secRangeID = $range_id[1];
         $rangeID = $range_id[0];
         // to keep compatible with following code
         if ('usersemdata' !== $object_type && 'roleinstdata' !== $object_type) {
             $object_type = 'userinstrole';
         }
         $clause1 = "AND sec_range_id= :sec_range_id";
         $parameters[':sec_range_id'] = $secRangeID;
     } else {
         $rangeID = $range_id;
     }
     if (!$object_type) {
         $object_type = get_object_type($rangeID);
     }
     if ($object_type) {
         switch ($object_type) {
             case 'sem':
                 if ($object_class_hint) {
                     $object_class = SeminarCategories::GetByTypeId($object_class_hint);
                 } else {
                     $object_class = SeminarCategories::GetBySeminarId($rangeID);
                 }
                 $clause2 = "object_class = :object_class OR object_class IS NULL";
                 $parameters[':object_class'] = (int) $object_class->id;
                 break;
             case 'inst':
             case 'fak':
                 if ($object_class_hint) {
                     $object_class = $object_class_hint;
                 } else {
                     $query = "SELECT type FROM Institute WHERE Institut_id = ?";
                     $statement = DBManager::get()->prepare($query);
                     $statement->execute(array($rangeID));
                     $object_class = $statement->fetchColumn();
                 }
                 $object_type = "inst";
                 $clause2 = "object_class = :object_class OR object_class IS NULL";
                 $parameters[':object_class'] = (int) $object_class;
                 break;
             case 'roleinstdata':
                 //hmm tja, vermutlich so
                 $clause2 = '1';
                 break;
             case 'user':
             case 'userinstrole':
             case 'usersemdata':
                 $object_class = is_object($GLOBALS['perm']) ? DataField::permMask($GLOBALS['perm']->get_perm($rangeID)) : 0;
                 $clause2 = "((object_class & :object_class) OR object_class IS NULL)";
                 $parameters[':object_class'] = (int) $object_class;
                 break;
         }
         $query = "SELECT a.*, content\n                      FROM datafields AS a\n                      LEFT JOIN datafields_entries AS b\n                        ON (a.datafield_id = b.datafield_id AND range_id = :range_id {$clause1})\n                      WHERE object_type = :object_type AND ({$clause2})\n                      ORDER BY priority";
         $parameters[':range_id'] = $rangeID;
         $parameters[':object_type'] = $object_type;
         $rs = DBManager::get()->prepare($query);
         $rs->execute($parameters);
         $entries = array();
         while ($data = $rs->fetch(PDO::FETCH_ASSOC)) {
             $datafield = DataField::buildExisting($data);
             $entries[$data['datafield_id']] = DataFieldEntry::createDataFieldEntry($datafield, $range_id, $data['content']);
         }
     }
     return $entries;
 }
Exemplo n.º 2
0
:

            <select multiple size="<?php 
echo count($controller->user_status);
?>
" name="object_class[]" id="object_class" required>
                <option value="0" <? if ($item->object_class === null) echo 'selected'; ?>>
                    <?php 
echo _('alle');
?>
                </option>
            <? foreach ($controller->user_status as $key => $value): ?>
                <option value="<?php 
echo $value;
?>
" <? if ($item->object_class & DataField::permMask($key)) echo 'selected'; ?>>
                    <?php 
echo $key;
?>
                </option>
            <? endforeach; ?>
            </select>
        <? endif; ?>
        </label>

        <label>
            <?php 
echo _('Benötigter Status zum Bearbeiten');
?>

            <select name="edit_perms" id="edit_perms">