Fix installation process

pull/3064/head
Julio 5 years ago
parent 667dde3c3d
commit 6565d6d213
  1. 2
      public/main/install/index.php
  2. 56
      public/main/install/install.lib.php
  3. 2
      src/CoreBundle/Tool/AbstractTool.php
  4. 38
      src/CoreBundle/ToolChain.php

@ -224,6 +224,8 @@ if ($installType === 'update' && in_array($my_old_version, $update_from_version_
}
$showEmailNotCheckedToStudent = 1;
$userMailCanBeEmpty = null;
$checkEmailByHashSent = null;
if (!isset($_GET['running'])) {
// Extract the path to append to the url if Chamilo is not installed on the web root directory.

@ -412,7 +412,7 @@ function write_system_config_file($path)
Your problems can be related on two possible causes:<br />
<ul>
<li>Permission problems.<br />Try initially with <em>chmod -R 777</em> and increase restrictions gradually.</li>
<li>PHP is running in <a href="http://www.php.net/manual/en/features.safe-mode.php" target="_blank">Safe-Mode</a>.
<li>PHP is running in <a href="http://www.php.net/manual/en/features.safe-mode.php" target="_blank">Safe-Mode</a>.
If possible, try to switch it off.</li>
</ul>
<a href="http://forum.chamilo.org/" target="_blank">Read about this problem in Support Forum</a><br /><br />
@ -877,7 +877,7 @@ function display_requirements(
<th>'.get_lang('(recommended)').'</th>
<th>'.get_lang('Currently').'</th>
</tr>
<tr>
<td class="requirements-item"><a href="http://php.net/manual/ref.errorfunc.php#ini.display-errors">Display Errors</a></td>
<td class="requirements-recommended">'.Display::label('OFF', 'success').'</td>
@ -953,7 +953,7 @@ function display_requirements(
<tr>
<td class="requirements-item">'.api_get_path(SYS_PATH).'</td>
<td class="requirements-value">'.check_writable(api_get_path(SYS_PATH)).'</td>
</tr>
</tr>
<tr>
<td class="requirements-item">'.get_lang('Permissions for new directories').'</td>
<td class="requirements-value">'.$dir_perm.' </td>
@ -1809,7 +1809,7 @@ function display_after_install_message()
'To protect your site, make the whole %s directory read-only (chmod -R 0555 on Linux) and delete the %s directory.'), 'var/config/', 'main/install/');
$html .= '</div></form>
<br />
<a class="btn btn-success btn-block" href="../../index.php">
<a class="btn btn-success btn-block" href="../../">
'.$trans->trans('Go to your newly created portal.').'
</a>';
@ -2689,7 +2689,7 @@ function fixLpId($connection, $debug)
$correctLink = "lp/lp_controller.php?action=view&lp_id=$lpIid&id_session=$sessionId";
$link = "newscorm/lp_controller.php?action=view&lp_id=$oldId&id_session=$sessionId";
$secondLink = "lp/lp_controller.php?action=view&lp_id=$oldId&id_session=$sessionId";
$sql = "UPDATE $toolTable
$sql = "UPDATE $toolTable
SET link = '$correctLink'
WHERE c_id = $courseId AND (link = '$link' OR link ='$secondLink')";
$connection->query($sql);
@ -2701,7 +2701,7 @@ function fixLpId($connection, $debug)
foreach ($variablesToFix as $variable) {
if (!empty($item[$variable]) && isset($itemList[$item[$variable]])) {
$newId = $itemList[$item[$variable]];
$sql = "UPDATE $tblCLpItem SET $variable = $newId
$sql = "UPDATE $tblCLpItem SET $variable = $newId
WHERE iid = $itemIid AND c_id = $courseId AND lp_id = $oldId";
$connection->query($sql);
}
@ -2715,7 +2715,7 @@ function fixLpId($connection, $debug)
if (!empty($document)) {
$newDocumentId = $document['iid'];
if (!empty($newDocumentId)) {
$sql = "UPDATE $tblCLpItem SET path = $newDocumentId
$sql = "UPDATE $tblCLpItem SET path = $newDocumentId
WHERE iid = $itemIid AND c_id = $courseId";
$connection->query($sql);
if ($debug) {
@ -2727,22 +2727,22 @@ function fixLpId($connection, $debug)
}
// c_lp_view
$sql = "UPDATE c_lp_view SET last_item = $itemIid
$sql = "UPDATE c_lp_view SET last_item = $itemIid
WHERE c_id = $courseId AND last_item = $itemId AND lp_id = $oldId";
$connection->query($sql);
// c_lp_item_view
$sql = "UPDATE c_lp_item_view SET lp_item_id = $itemIid
$sql = "UPDATE c_lp_item_view SET lp_item_id = $itemIid
WHERE c_id = $courseId AND lp_item_id = $itemId";
$connection->query($sql);
// Update track_exercises
$sql = "UPDATE track_e_exercises SET orig_lp_item_id = $itemIid
$sql = "UPDATE track_e_exercises SET orig_lp_item_id = $itemIid
WHERE c_id = $courseId AND orig_lp_id = $oldId AND orig_lp_item_id = $itemId";
$connection->query($sql);
// c_forum_thread
$sql = "UPDATE c_forum_thread SET lp_item_id = $itemIid
$sql = "UPDATE c_forum_thread SET lp_item_id = $itemIid
WHERE c_id = $courseId AND lp_item_id = $itemId";
$connection->query($sql);
@ -2761,14 +2761,14 @@ function fixLpId($connection, $debug)
continue;
}
$sql = "UPDATE track_e_exercises
SET orig_lp_item_view_id = $newItemView
WHERE
c_id = $courseId AND
orig_lp_id = $oldId AND
orig_lp_item_id = $itemIid AND
orig_lp_item_view_id = $oldItemViewId AND
exe_user_id = $userId
$sql = "UPDATE track_e_exercises
SET orig_lp_item_view_id = $newItemView
WHERE
c_id = $courseId AND
orig_lp_id = $oldId AND
orig_lp_item_id = $itemIid AND
orig_lp_item_view_id = $oldItemViewId AND
exe_user_id = $userId
";
$connection->query($sql);
@ -2782,11 +2782,11 @@ function fixLpId($connection, $debug)
}
}
$sql = "UPDATE $tblCLpItem SET lp_id = $lpIid
$sql = "UPDATE $tblCLpItem SET lp_id = $lpIid
WHERE c_id = $courseId AND lp_id = $oldId AND id = $itemId";
$connection->query($sql);
$sql = "UPDATE $tblCLpItem SET id = iid
$sql = "UPDATE $tblCLpItem SET id = iid
WHERE c_id = $courseId AND lp_id = $oldId AND id = $itemId";
$connection->query($sql);
}
@ -2798,7 +2798,7 @@ function fixLpId($connection, $debug)
$connection->query($sql);
// Update track_exercises.
$sql = "UPDATE track_e_exercises SET orig_lp_id = $lpIid
$sql = "UPDATE track_e_exercises SET orig_lp_id = $lpIid
WHERE c_id = $courseId AND orig_lp_id = $oldId";
$connection->query($sql);
@ -3662,7 +3662,7 @@ function fixPostGroupIds($connection)
error_log('Fix c_student_publication.post_group_id');
// Fix post_group_id
$sql = "SELECT * FROM c_student_publication
$sql = "SELECT * FROM c_student_publication
WHERE (post_group_id <> 0 AND post_group_id is not null)";
$statement = $connection->executeQuery($sql);
$result = $statement->fetchAll();
@ -3671,7 +3671,7 @@ function fixPostGroupIds($connection)
$groupId = $row['post_group_id'];
$courseId = $row['c_id'];
$workIid = $row['iid'];
$sql = "SELECT iid from c_group_info
$sql = "SELECT iid from c_group_info
WHERE c_id = $courseId AND id = $groupId";
$statement = $connection->executeQuery($sql);
$count = $statement->rowCount();
@ -3682,9 +3682,9 @@ function fixPostGroupIds($connection)
continue;
}
if ($newGroupId) {
$sql = "UPDATE c_student_publication
SET post_group_id = $newGroupId
WHERE
$sql = "UPDATE c_student_publication
SET post_group_id = $newGroupId
WHERE
c_id = $courseId AND
iid = $workIid
";
@ -3696,7 +3696,7 @@ function fixPostGroupIds($connection)
error_log('End - Fix c_student_publication.post_group_id');
// Delete c_student_publication from any session that doesn't exist anymore
$sql = "DELETE FROM c_student_publication
$sql = "DELETE FROM c_student_publication
WHERE session_id NOT IN (SELECT id FROM session) AND (session_id <> 0 AND session_id is not null)";
$connection->executeQuery($sql);

@ -112,7 +112,7 @@ abstract class AbstractTool implements ToolInterface
/**
* @return array
*/
public function getResourceTypes(): array
public function getResourceTypes()
{
return $this->resourceTypes;
}

@ -90,10 +90,44 @@ class ToolChain
$types = $tool->getResourceTypes();
if (!empty($types)) {
foreach ($types as $entityName => $name) {
foreach ($types as $name => $data) {
$resourceType = new ResourceType();
$resourceType->setName($name);
$resourceType->setEntityName($entityName);
$resourceType->setEntityName($data['entity']);
$resourceType->setTool($toolEntity);
$manager->persist($resourceType);
}
}
$manager->flush();
}
}
public function updateTools(ObjectManager $manager): void
{
$tools = $this->getTools();
/** @var AbstractTool $tool */
foreach ($tools as $tool) {
$toolEntity = new Tool();
$toolEntity
->setName($tool->getName())
;
if ($tool->getAdmin() === 1) {
// Only check ROLE_ADMIN
} else {
$this->setToolPermissions($toolEntity);
}
$manager->persist($toolEntity);
$types = $tool->getResourceTypes();
if (!empty($types)) {
foreach ($types as $name => $data) {
$resourceType = new ResourceType();
$resourceType->setName($name);
$resourceType->setEntityName($data['entity']);
$resourceType->setTool($toolEntity);
$manager->persist($resourceType);
}

Loading…
Cancel
Save