Esempio n. 1
0
function SubSortStatusgruppe($insert_father, $insert_daughter) {
    if ($insert_father == '' || $insert_daughter == '') return FALSE;
    if (isVatherDaughterRelation($insert_father, $insert_daughter)) return FALSE;

    $query = "SELECT MAX(position) FROM statusgruppen WHERE range_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement-execute(array($insert_daughter));
    $position = $statement->fetchColumn() + 1;

    $query = "UPDATE statusgruppen SET position = ?, range_id = ? WHERE statusgruppe_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($position, $insert_daughter, $insert_father));

    return TRUE;
}
Esempio n. 2
0
 function checkData()
 {
     global $invalidEntries;
     // check the standard role data
     if (!Request::get('new_name') && Request::get('presetName') != 'none') {
         $this->name = remove_magic_quotes(Request::get('presetName'));
     } else {
         $this->name = remove_magic_quotes(Request::get('new_name'));
     }
     $this->size = (int) Request::int('new_size');
     // check if we have to remove the self_assign_exclusive-flag
     $this->selfassign = SetSelfAssign($this->statusgruppe_id, Request::quoted('new_selfassign') ? 1 : 0);
     /*if (Request::quoted('new_selfassign')) {
           if ($this->selfassign == 0) {
               $this->selfassign = 1;
           }
       } else {
           if ($this->selfassign == 2) {
               if ($GLOBALS['SessSemName']) {
                   SetSelfAssignExclusive($GLOBALS['SessSemName'][1], false);
               }
           }
           $this->selfassign = 0;
       }*/
     if (Request::get('groupfolder')) {
         // check if there already exists a folder
         $stmt = DBManager::get()->prepare("SELECT COUNT(*) as c FROM folder WHERE range_id = ?");
         $stmt->execute(array($this->statusgruppe_id));
         if ($folder = $stmt->fetch(PDO::FETCH_ASSOC)) {
             if ($folder['c'] == 0) {
                 // if no folder exists, we create one
                 $title = _("Dateiordner der Gruppe:") . ' ' . $this->name;
                 $description = _("Ablage für Ordner und Dokumente dieser Gruppe");
                 $permission = 15;
                 create_folder(addslashes($title), $description, $this->statusgruppe_id, $permission);
                 $this->messages['msg'][] = _("Es wurde ein Gruppenordner angelegt.");
             }
         }
     }
     if (!$this->isSeminar()) {
         // check the datafields
         foreach (Request::quotedArray('datafields') as $id => $data) {
             $struct = DataField::find($id);
             $entry = DataFieldEntry::createDataFieldEntry($struct, array($this->range_id, $this->statusgruppe_id));
             $entry->setValueFromSubmit($data);
             if ($entry->isValid()) {
                 $entry->store();
             } else {
                 $invalidEntries[$struct->id] = $entry;
             }
         }
         // a group cannot be its own vather!
         if (Request::get('vather') == $this->statusgruppe_id) {
             $this->messages['error'][] = _("Sie könne diese Gruppe nicht sich selbst unterordnen!");
         } else {
             // check if the group shall be moved
             if (Request::get('vather') != 'nochange') {
                 if (Request::option('vather') == 'root') {
                     $vather_id = $GLOBALS['range_id'];
                 } else {
                     $vather_id = Request::option('vather');
                 }
                 if (!isVatherDaughterRelation($this->statusgruppe_id, $vather_id)) {
                     $this->range_id = $vather_id;
                     //$db->query("UPDATE statusgruppen SET range_id = '$vather_id' WHERE statusgruppe_id = '{$this->statusgruppe_id}'");
                 } else {
                     $this->messages['error'][] = _("Sie können diese Gruppe nicht einer ihr untergeordneten Gruppe zuweisen!");
                 }
             }
         }
     }
     if (!$this->isSeminar() && is_array($invalidEntries)) {
         $this->messages['error'][] = _("Korrigieren Sie die fehlerhaften Eingaben!");
         return false;
     }
     return true;
 }