/**
  * Removes operator's avatar from the database.
  *
  * @param Request $request Incoming request.
  * @return string Rendered page content.
  * @throws NotFoundException If the operator with specified ID is not found
  *   in the system.
  */
 public function deleteAction(Request $request)
 {
     csrf_check_token($request);
     $operator = $this->getOperator();
     $op_id = $request->attributes->getInt('operator_id');
     // Try to load the target operator.
     if (!operator_by_id($op_id)) {
         throw new NotFoundException('The operator is not found');
     }
     // Try to remove the current operator's avatar if it exists.
     $current_avatar = $operator['vcavatar'];
     if ($current_avatar) {
         @unlink(MIBEW_FS_ROOT . '/files/avatar/' . basename($current_avatar));
     }
     // Update avatar value in database
     update_operator_avatar($op_id, '');
     // Redirect the current operator to the same page using GET method.
     $redirect_to = $this->generateUrl('operator_avatar', array('operator_id' => $op_id));
     return $this->redirect($redirect_to);
 }
Beispiel #2
0
                    }
                }
            } else {
                $errors[] = "No file selected";
            }
        }
        if (count($errors) == 0) {
            update_operator_avatar($op['operatorid'], $avatar);
            if ($opId && $avatar && $_SESSION["{$mysqlprefix}operator"] && $operator['operatorid'] == $opId) {
                $_SESSION["{$mysqlprefix}operator"]['vcavatar'] = $avatar;
            }
            header("Location: {$mibewroot}/operator/avatar.php?op=" . intval($opId));
            exit;
        } else {
            $page['avatar'] = topage($op['vcavatar']);
        }
    } else {
        if (isset($_GET['act']) && $_GET['act'] == 'del' && $canmodify) {
            update_operator_avatar($op['operatorid'], '');
            header("Location: {$mibewroot}/operator/avatar.php?op=" . intval($opId));
            exit;
        }
        $page['avatar'] = topage($op['vcavatar']);
    }
}
$page['currentop'] = $op ? topage(get_operator_name($op)) . " (" . $op['vclogin'] . ")" : "-not found-";
$page['canmodify'] = $canmodify ? "1" : "";
prepare_menu($operator);
setup_operator_settings_tabs($opId, 1);
start_html_output();
require '../view/avatar.php';