Minor - format code, set namespace at the beginning of file.

pull/2487/head
jmontoyaa 8 years ago
parent 28a1ab4349
commit f423cdd156
  1. 3
      main/exercise/unique_answer.class.php
  2. 3
      main/inc/lib/CourseChatUtils.php
  3. 8
      main/inc/lib/add_course.lib.inc.php
  4. 6
      main/inc/lib/extra_field.lib.php
  5. 13
      main/inc/lib/pear/HTML/QuickForm.php
  6. 92
      main/inc/lib/plugin.class.php
  7. 6
      main/inc/lib/webservices/Rest.php

@ -2,6 +2,7 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use ChamiloSession as Session; use ChamiloSession as Session;
use Chamilo\CourseBundle\Entity\CQuizAnswer;
/** /**
* Class UniqueAnswer * Class UniqueAnswer
@ -463,7 +464,7 @@ class UniqueAnswer extends Question
$position = $row_max->max_position + 1; $position = $row_max->max_position + 1;
// Insert a new answer // Insert a new answer
$quizAnswer = new \Chamilo\CourseBundle\Entity\CQuizAnswer(); $quizAnswer = new CQuizAnswer();
$quizAnswer $quizAnswer
->setCId($course_id) ->setCId($course_id)
->setId($id) ->setId($id)

@ -3,6 +3,7 @@
use Michelf\MarkdownExtra; use Michelf\MarkdownExtra;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Chamilo\CourseBundle\Entity\CChatConnected;
/** /**
* Class CourseChat * Class CourseChat
@ -319,7 +320,7 @@ class CourseChatUtils
return; return;
} }
$connection = new \Chamilo\CourseBundle\Entity\CChatConnected(); $connection = new CChatConnected();
$connection $connection
->setCId($this->courseId) ->setCId($this->courseId)
->setUserId($this->userId) ->setUserId($this->userId)

@ -1,6 +1,8 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CToolIntro;
/** /**
* Class AddCourse * Class AddCourse
*/ */
@ -956,7 +958,7 @@ class AddCourse
<h2>' . get_lang('IntroductionText').'</h2> <h2>' . get_lang('IntroductionText').'</h2>
</p>'; </p>';
$toolIntro = new Chamilo\CourseBundle\Entity\CToolIntro(); $toolIntro = new CToolIntro();
$toolIntro $toolIntro
->setCId($course_id) ->setCId($course_id)
->setId(TOOL_COURSE_HOMEPAGE) ->setId(TOOL_COURSE_HOMEPAGE)
@ -964,7 +966,7 @@ class AddCourse
->setIntroText($intro_text); ->setIntroText($intro_text);
$manager->persist($toolIntro); $manager->persist($toolIntro);
$toolIntro = new Chamilo\CourseBundle\Entity\CToolIntro(); $toolIntro = new CToolIntro();
$toolIntro $toolIntro
->setCId($course_id) ->setCId($course_id)
->setId(TOOL_STUDENTPUBLICATION) ->setId(TOOL_STUDENTPUBLICATION)
@ -972,7 +974,7 @@ class AddCourse
->setIntroText(get_lang('IntroductionTwo')); ->setIntroText(get_lang('IntroductionTwo'));
$manager->persist($toolIntro); $manager->persist($toolIntro);
$toolIntro = new Chamilo\CourseBundle\Entity\CToolIntro(); $toolIntro = new CToolIntro();
$toolIntro $toolIntro
->setCId($course_id) ->setCId($course_id)
->setId(TOOL_WIKI) ->setId(TOOL_WIKI)

@ -1184,7 +1184,10 @@ class ExtraField extends Model
'extra_'.$field_details['variable'], 'extra_'.$field_details['variable'],
$field_details['display_text'], $field_details['display_text'],
$options, $options,
array('multiple' => 'multiple', 'id' => 'extra_'.$field_details['variable']) array(
'multiple' => 'multiple',
'id' => 'extra_'.$field_details['variable']
)
); );
if ($freezeElement) { if ($freezeElement) {
$form->freeze('extra_'.$field_details['variable']); $form->freeze('extra_'.$field_details['variable']);
@ -2634,7 +2637,6 @@ JAVASCRIPT;
continue; continue;
} }
if (strpos($rule->field, '_second') === false) { if (strpos($rule->field, '_second') === false) {
} else { } else {
$my_field = str_replace('_second', '', $rule->field); $my_field = str_replace('_second', '', $rule->field);
$double_select[$my_field] = $rule->data; $double_select[$my_field] = $rule->data;

@ -1,6 +1,4 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Create, validate and process HTML forms * Create, validate and process HTML forms
* *
@ -31,9 +29,6 @@
* @global array $GLOBALS['_HTML_QuickForm_registered_rules'] * @global array $GLOBALS['_HTML_QuickForm_registered_rules']
*/ */
// {{{ error codes
/**#@+ /**#@+
* Error codes for HTML_QuickForm * Error codes for HTML_QuickForm
* *
@ -52,9 +47,6 @@ define('QUICKFORM_INVALID_ELEMENT_NAME', -6);
define('QUICKFORM_INVALID_PROCESS', -7); define('QUICKFORM_INVALID_PROCESS', -7);
define('QUICKFORM_DEPRECATED', -8); define('QUICKFORM_DEPRECATED', -8);
define('QUICKFORM_INVALID_DATASOURCE', -9); define('QUICKFORM_INVALID_DATASOURCE', -9);
/**#@-*/
// }}}
/** /**
* Class HTML_QuickForm * Class HTML_QuickForm
@ -346,11 +338,10 @@ class HTML_QuickForm extends HTML_Common
/** /**
* Initializes default form values * Initializes default form values
* *
* @param array $defaultValues values used to fill the form * @param array $defaultValues values used to fill the form
* @param mixed $filter (optional) filter(s) to apply to all default values * @param mixed $filter (optional) filter(s) to apply to all default values
* @since 1.0 * @since 1.0
* @access public * @access public
* @return void
*/ */
public function setDefaults($defaultValues = null, $filter = null) public function setDefaults($defaultValues = null, $filter = null)
{ {

@ -509,16 +509,60 @@ class Plugin
$this->createLinkToCourseTool($plugin_name, $courseId); $this->createLinkToCourseTool($plugin_name, $courseId);
} }
/**
* Delete the fields added to the course settings page and the link to the
* tool on the course's homepage
* @param int $courseId
*
* @return false|null
*/
public function uninstall_course_fields($courseId)
{
$courseId = intval($courseId);
if (empty($courseId)) {
return false;
}
$plugin_name = $this->get_name();
$t_course = Database::get_course_table(TABLE_COURSE_SETTING);
$t_tool = Database::get_course_table(TABLE_TOOL_LIST);
if (!empty($this->course_settings)) {
foreach ($this->course_settings as $setting) {
$variable = Database::escape_string($setting['name']);
if (!empty($setting['group'])) {
$variable = Database::escape_string($setting['group']);
}
if (empty($variable)) {
continue;
}
$sql = "DELETE FROM $t_course
WHERE c_id = $courseId AND variable = '$variable'";
Database::query($sql);
}
}
$plugin_name = Database::escape_string($plugin_name);
$sql = "DELETE FROM $t_tool
WHERE c_id = $courseId AND name = '$plugin_name'";
Database::query($sql);
}
/** /**
* Add an link for a course tool * Add an link for a course tool
* @param string $name The tool name * @param string $name The tool name
* @param int $courseId The course ID * @param int $courseId The course ID
* @param string $iconName Optional. Icon file name * @param string $iconName Optional. Icon file name
* @param string $link Optional. Link URL * @param string $link Optional. Link URL
* @return \Chamilo\CourseBundle\Entity\CTool|null * @return CTool|null
*/ */
protected function createLinkToCourseTool($name, $courseId, $iconName = null, $link = null) protected function createLinkToCourseTool(
{ $name,
$courseId,
$iconName = null,
$link = null
) {
if (!$this->addCourseTool) { if (!$this->addCourseTool) {
return null; return null;
} }
@ -559,46 +603,6 @@ class Plugin
return $tool; return $tool;
} }
/**
* Delete the fields added to the course settings page and the link to the
* tool on the course's homepage
* @param int $courseId
*
* @return false|null
*/
public function uninstall_course_fields($courseId)
{
$courseId = intval($courseId);
if (empty($courseId)) {
return false;
}
$plugin_name = $this->get_name();
$t_course = Database::get_course_table(TABLE_COURSE_SETTING);
$t_tool = Database::get_course_table(TABLE_TOOL_LIST);
if (!empty($this->course_settings)) {
foreach ($this->course_settings as $setting) {
$variable = Database::escape_string($setting['name']);
if (!empty($setting['group'])) {
$variable = Database::escape_string($setting['group']);
}
if (empty($variable)) {
continue;
}
$sql = "DELETE FROM $t_course
WHERE c_id = $courseId AND variable = '$variable'";
Database::query($sql);
}
}
$plugin_name = Database::escape_string($plugin_name);
$sql = "DELETE FROM $t_tool
WHERE c_id = $courseId AND name = '$plugin_name'";
Database::query($sql);
}
/** /**
* Install the course fields and tool link of this plugin in all courses * Install the course fields and tool link of this plugin in all courses
* @param boolean $add_tool_link Whether we want to add a plugin link on the course homepage * @param boolean $add_tool_link Whether we want to add a plugin link on the course homepage

@ -8,6 +8,7 @@ use Chamilo\CourseBundle\Entity\Repository\CNotebookRepository;
use Chamilo\CourseBundle\Entity\CLpCategory; use Chamilo\CourseBundle\Entity\CLpCategory;
use Chamilo\CoreBundle\Entity\Session; use Chamilo\CoreBundle\Entity\Session;
use Chamilo\UserBundle\Entity\User; use Chamilo\UserBundle\Entity\User;
use Chamilo\CourseBundle\Entity\CNotebook;
/** /**
* Class RestApi * Class RestApi
@ -482,7 +483,7 @@ class Rest extends WebService
$notebooks = $notebooksRepo->findByUser($this->user, $this->course, $this->session); $notebooks = $notebooksRepo->findByUser($this->user, $this->course, $this->session);
return array_map( return array_map(
function(\Chamilo\CourseBundle\Entity\CNotebook $notebook) { function (CNotebook $notebook) {
return [ return [
'id' => $notebook->getIid(), 'id' => $notebook->getIid(),
'title' => $notebook->getTitle(), 'title' => $notebook->getTitle(),
@ -687,13 +688,12 @@ class Rest extends WebService
$sessionId = $this->session ? $this->session->getId() : 0; $sessionId = $this->session ? $this->session->getId() : 0;
$categoriesTempList = learnpath::getCategories($this->course->getId()); $categoriesTempList = learnpath::getCategories($this->course->getId());
$categoryNone = new \Chamilo\CourseBundle\Entity\CLpCategory(); $categoryNone = new CLpCategory();
$categoryNone->setId(0); $categoryNone->setId(0);
$categoryNone->setName(get_lang('WithOutCategory')); $categoryNone->setName(get_lang('WithOutCategory'));
$categoryNone->setPosition(0); $categoryNone->setPosition(0);
$categories = array_merge([$categoryNone], $categoriesTempList); $categories = array_merge([$categoryNone], $categoriesTempList);
$categoryData = array(); $categoryData = array();
/** @var CLpCategory $category */ /** @var CLpCategory $category */

Loading…
Cancel
Save