Esempio n. 1
0
 /**
  * Deletes the selected record of the table and all references in other tables.
  * After that the class will be initialize.
  * @return bool @b true if no error occurred
  */
 public function delete()
 {
     $this->db->startTransaction();
     $sql = 'DELETE FROM ' . TBL_DATE_ROLE . ' WHERE dtr_dat_id = ' . $this->getValue('dat_id');
     $this->db->query($sql);
     // if date has participants then the role with their memberships must be deleted
     if ($this->getValue('dat_rol_id') > 0) {
         $sql = 'UPDATE ' . TBL_DATES . ' SET dat_rol_id = NULL WHERE dat_id = ' . $this->getValue('dat_id');
         $this->db->query($sql);
         $dateRole = new TableRoles($this->db, $this->getValue('dat_rol_id'));
         $dateRole->delete();
     }
     parent::delete();
     return $this->db->endTransaction();
 }
Esempio n. 2
0
 /**
  * This method deletes all roles that belongs to still deleted dates.
  */
 public function updateStepDeleteDateRoles()
 {
     $sql = 'select rol_id from ' . TBL_CATEGORIES . ', ' . TBL_ROLES . '
              where cat_name_intern LIKE \'CONFIRMATION_OF_PARTICIPATION\'
                and rol_cat_id = cat_id
                and not exists (select 1 from ' . TBL_DATES . ' where dat_rol_id = rol_id)';
     $rolesStatement = $this->db->query($sql);
     while ($row = $rolesStatement->fetch()) {
         $role = new TableRoles($this->db, $row['rol_id']);
         $role->delete();
     }
 }
Esempio n. 3
0
         $date->delete();
         $gMessage->show($gL10n->get('SYS_NO_RIGHTS'));
     }
     // dat_rol_id anpassen (Referenz zwischen date und role)
     $date->setValue('dat_rol_id', $role->getValue('rol_id'));
     $return_code = $date->save();
     if ($return_code < 0) {
         $role->delete();
         $gMessage->show($gL10n->get('SYS_NO_RIGHTS'));
     }
 } elseif ($_POST['date_registration_possible'] == 0 && $date->getValue('dat_rol_id') > 0) {
     // date participation was deselected -> delete flag in event and than delete role
     $role = new TableRoles($gDb, $date->getValue('dat_rol_id'));
     $date->setValue('dat_rol_id', '');
     $date->save();
     $role->delete();
 } elseif ($_POST['date_registration_possible'] == 1 && $date->getValue('dat_rol_id') > 0) {
     // if event exists and you could register to this event then we must check
     // if the data of the role must be changed
     $role = new TableRoles($gDb, $date->getValue('dat_rol_id'));
     $roleName = $gL10n->get('DAT_DATE') . ' ' . $date->getValue('dat_begin', 'Y-m-d H:i') . ' - ' . $date->getValue('dat_id');
     if ($role->getValue('rol_max_members') != $date->getValue('dat_max_members') || $role->getValue('role_name' != $roleName)) {
         $role->setValue('rol_name', $roleName);
         $role->setValue('rol_max_members', $date->getValue('dat_max_members'));
         $role->save();
     }
 }
 // check if flag is set that current user wants to participate as leader to the date
 if (isset($_POST['date_current_user_assigned']) && $_POST['date_current_user_assigned'] == 1 && $gCurrentUser->isLeaderOfRole($date->getValue('dat_rol_id')) == false) {
     // user wants to participate -> add him to date
     $member = new TableMembers($gDb);
Esempio n. 4
0
 /**
  * This method deletes all roles that belongs to still deleted dates.
  */
 public function updateStepDeleteDateRoles()
 {
     $sql = 'SELECT rol_id
               FROM ' . TBL_ROLES . '
         INNER JOIN ' . TBL_CATEGORIES . '
                 ON cat_id = rol_cat_id
              WHERE cat_name_intern LIKE \'CONFIRMATION_OF_PARTICIPATION\'
                AND NOT exists (SELECT 1
                                  FROM ' . TBL_DATES . '
                                 WHERE dat_rol_id = rol_id)';
     $rolesStatement = $this->db->query($sql);
     while ($row = $rolesStatement->fetch()) {
         $role = new TableRoles($this->db, $row['rol_id']);
         $role->delete();
     }
 }