Skip to content

Commit

Permalink
Portfolio: Rename variable - refs BT#18201
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Dec 28, 2020
1 parent 18296ba commit 0a81976
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion main/portfolio/add_category.php
Expand Up @@ -21,7 +21,7 @@
$category
->setTitle($values['title'])
->setDescription($values['description'])
->setUser($user);
->setUser($owner);

$em->persist($category);
$em->flush();
Expand Down
4 changes: 2 additions & 2 deletions main/portfolio/add_item.php
Expand Up @@ -6,7 +6,7 @@

$categories = $em
->getRepository('ChamiloCoreBundle:PortfolioCategory')
->findBy(['user' => $user]);
->findBy(['user' => $owner]);

$form = new FormValidator('add_portfolio', 'post', $baseUrl.'action=add_item');
if (api_get_configuration_value('save_titles_as_html')) {
Expand All @@ -30,7 +30,7 @@
$portfolio
->setTitle($values['title'])
->setContent($values['content'])
->setUser($user)
->setUser($owner)
->setCourse($course)
->setSession($session)
->setCategory(
Expand Down
2 changes: 1 addition & 1 deletion main/portfolio/edit_item.php
Expand Up @@ -4,7 +4,7 @@

$categories = $em
->getRepository('ChamiloCoreBundle:PortfolioCategory')
->findBy(['user' => $user]);
->findBy(['user' => $owner]);

$form = new FormValidator('edit_portfolio', 'post', $baseUrl."action=edit_item&id={$item->getId()}");
if (api_get_configuration_value('save_titles_as_html')) {
Expand Down
17 changes: 7 additions & 10 deletions main/portfolio/index.php
Expand Up @@ -23,18 +23,15 @@
$em = Database::getManager();

$currentUserId = api_get_user_id();
$userId = isset($_GET['user']) ? (int) $_GET['user'] : $currentUserId;
/** @var User $user */
$user = api_get_user_entity($userId);
/** @var Course $course */
$course = $em->find('ChamiloCoreBundle:Course', api_get_course_int_id());
/** @var Session $session */
$session = $em->find('ChamiloCoreBundle:Session', api_get_session_id());
$ownerId = isset($_GET['user']) ? (int) $_GET['user'] : $currentUserId;
$owner = api_get_user_entity($ownerId);
$course = api_get_course_entity(api_get_course_int_id());
$session = api_get_session_entity(api_get_session_id());

$action = isset($_GET['action']) ? $_GET['action'] : 'list';
$cidreq = api_get_cidreq();
$baseUrl = api_get_self().'?'.($cidreq ? $cidreq.'&' : '');
$allowEdit = $currentUserId == $user->getId();
$allowEdit = $currentUserId == $owner->getId();

if (isset($_GET['preview'])) {
$allowEdit = false;
Expand All @@ -51,7 +48,7 @@
*
* @return bool
*/
$isValid = function ($item) use ($user, $course, $session) {
$isValid = function ($item) use ($owner, $course, $session) {
if (!$item) {
return false;
}
Expand All @@ -66,7 +63,7 @@
}
}

if ($item->getUser()->getId() != $user->getId()) {
if ($item->getUser()->getId() != $owner->getId()) {
return false;
}

Expand Down
10 changes: 5 additions & 5 deletions main/portfolio/list.php
Expand Up @@ -2,7 +2,7 @@

/* For licensing terms, see /license.txt */

if ($currentUserId == $user->getId()) {
if ($currentUserId == $owner->getId()) {
if ($allowEdit) {
$actions[] = Display::url(
Display::return_icon('add.png', get_lang('Add'), [], ICON_SIZE_MEDIUM),
Expand All @@ -14,7 +14,7 @@
);
$actions[] = Display::url(
Display::return_icon('shared_setting.png', get_lang('Preview'), [], ICON_SIZE_MEDIUM),
$baseUrl.'preview=&user='.$user->getId()
$baseUrl.'preview=&user='.$owner->getId()
);
} else {
$actions[] = Display::url(
Expand All @@ -26,9 +26,9 @@

$form = new FormValidator('a');
$form->addUserAvatar('user', get_lang('User'), 'medium');
$form->setDefaults(['user' => $user]);
$form->setDefaults(['user' => $owner]);

$criteria = ['user' => $user];
$criteria = ['user' => $owner];

if (!$allowEdit) {
$criteria['isVisible'] = true;
Expand All @@ -50,7 +50,7 @@
->findBy($criteria);

$template = new Template(null, false, false, false, false, false, false);
$template->assign('user', $user);
$template->assign('user', $owner);
$template->assign('course', $course);
$template->assign('session', $session);
$template->assign('allow_edit', $allowEdit);
Expand Down

0 comments on commit 0a81976

Please sign in to comment.