parent
							
								
									3f3dc24b02
								
							
						
					
					
						commit
						eb859c335d
					
				@ -0,0 +1,113 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * @author Julio Montoya <gugli100@gmail.com> Adding formvalidator support | 
				
			||||
 * | 
				
			||||
 * @package chamilo.learnpath | 
				
			||||
 */ | 
				
			||||
$this_section = SECTION_COURSES; | 
				
			||||
api_protect_course_script(); | 
				
			||||
 | 
				
			||||
require 'learnpath_functions.inc.php'; | 
				
			||||
require 'resourcelinker.inc.php'; | 
				
			||||
 | 
				
			||||
$language_file = 'learnpath'; | 
				
			||||
 | 
				
			||||
/* Header and action code */ | 
				
			||||
 | 
				
			||||
$currentstyle = api_get_setting('stylesheets'); | 
				
			||||
$htmlHeadXtra[] = '<script> | 
				
			||||
function setFocus(){ | 
				
			||||
    $("#learnpath_title").focus(); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$(document).ready(function () { | 
				
			||||
    setFocus(); | 
				
			||||
}); | 
				
			||||
 | 
				
			||||
function activate_start_date() { | 
				
			||||
	if(document.getElementById(\'start_date_div\').style.display == \'none\') { | 
				
			||||
		document.getElementById(\'start_date_div\').style.display = \'block\'; | 
				
			||||
	} else { | 
				
			||||
		document.getElementById(\'start_date_div\').style.display = \'none\'; | 
				
			||||
	} | 
				
			||||
} | 
				
			||||
 | 
				
			||||
function activate_end_date() { | 
				
			||||
    if(document.getElementById(\'end_date_div\').style.display == \'none\') { | 
				
			||||
        document.getElementById(\'end_date_div\').style.display = \'block\'; | 
				
			||||
    } else { | 
				
			||||
        document.getElementById(\'end_date_div\').style.display = \'none\'; | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
</script>'; | 
				
			||||
 | 
				
			||||
/* Constants and variables */ | 
				
			||||
 | 
				
			||||
$is_allowed_to_edit = api_is_allowed_to_edit(null, true); | 
				
			||||
 | 
				
			||||
$isStudentView  = isset($_REQUEST['isStudentView']) ? $_REQUEST['isStudentView'] : null; | 
				
			||||
$learnpath_id   = isset($_REQUEST['lp_id']) ? $_REQUEST['lp_id'] : null; | 
				
			||||
 | 
				
			||||
/* MAIN CODE */ | 
				
			||||
 | 
				
			||||
if ((!$is_allowed_to_edit) || ($isStudentView)) { | 
				
			||||
    //error_log('New LP - User not authorized in lp_add.php'); | 
				
			||||
    header('location:lp_controller.php?action=view&lp_id='.$learnpath_id); | 
				
			||||
    exit; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths')); | 
				
			||||
 | 
				
			||||
$form = new FormValidator('lp_add_category', 'post', 'lp_controller.php'); | 
				
			||||
 | 
				
			||||
// Form title | 
				
			||||
$form->addElement('header', null, get_lang('AddLPCategory')); | 
				
			||||
 | 
				
			||||
// Title | 
				
			||||
$form->addElement('text', 'name', api_ucfirst(get_lang('Name')), array('class' => 'span6')); | 
				
			||||
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); | 
				
			||||
 | 
				
			||||
$form->addElement('hidden', 'action', 'add_lp_category'); | 
				
			||||
$form->addElement('hidden', 'c_id', api_get_course_int_id()); | 
				
			||||
$form->addElement('hidden', 'id', 0); | 
				
			||||
 | 
				
			||||
$form->addElement('style_submit_button', 'Submit', get_lang('Save'),'class="save"'); | 
				
			||||
 | 
				
			||||
if ($form->validate()) { | 
				
			||||
    $values = $form->getSubmitValues(); | 
				
			||||
    if (!empty($values['id'])) { | 
				
			||||
        learnpath::updateCategory($values); | 
				
			||||
        $url = api_get_self().'?action=list&'.api_get_cidreq(); | 
				
			||||
        header('Location: '.$url); | 
				
			||||
        exit; | 
				
			||||
    } else { | 
				
			||||
        learnpath::createCategory($values); | 
				
			||||
        $url = api_get_self().'?action=list&'.api_get_cidreq(); | 
				
			||||
        header('Location: '.$url); | 
				
			||||
        exit; | 
				
			||||
    } | 
				
			||||
} else { | 
				
			||||
    $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; | 
				
			||||
 | 
				
			||||
    if ($id) { | 
				
			||||
        $item = learnpath::getCategory($id); | 
				
			||||
        $defaults = array( | 
				
			||||
            'id' => $item->getId(), | 
				
			||||
            'name' => $item->getName() | 
				
			||||
        ); | 
				
			||||
        $form->setDefaults($defaults); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
 | 
				
			||||
Display::display_header(get_lang('LearnpathAddLearnpath'), 'Path'); | 
				
			||||
 | 
				
			||||
echo '<div class="actions">'; | 
				
			||||
echo '<a href="lp_controller.php?'.api_get_cidreq().'">'. | 
				
			||||
    Display::return_icon('back.png', get_lang('ReturnToLearningPaths'),'',ICON_SIZE_MEDIUM).'</a>'; | 
				
			||||
echo '</div>'; | 
				
			||||
 | 
				
			||||
$form->display(); | 
				
			||||
 | 
				
			||||
Display::display_footer(); | 
				
			||||
									
										
											File diff suppressed because it is too large
											Load Diff
										
									
								
							
						@ -0,0 +1,30 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Chamilo\CoreBundle\Migrations\Schema\V110; | 
				
			||||
 | 
				
			||||
use Doctrine\DBAL\Schema\Schema; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Auto-generated Migration: Please modify to your needs! | 
				
			||||
 */ | 
				
			||||
class Version20150527114220 extends AbstractMigrationChamilo | 
				
			||||
{ | 
				
			||||
    /** | 
				
			||||
     * @param Schema $schema | 
				
			||||
     */ | 
				
			||||
    public function up(Schema $schema) | 
				
			||||
    { | 
				
			||||
        $this->addSql('CREATE TABLE c_lp_category (iid INT AUTO_INCREMENT NOT NULL, c_id INT NOT NULL, name VARCHAR(255) NOT NULL, position INT NOT NULL, PRIMARY KEY(iid)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); | 
				
			||||
        $this->addSql('ALTER TABLE c_lp ADD category_id INT NOT NULL DEFAULT 0'); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @param Schema $schema | 
				
			||||
     */ | 
				
			||||
    public function down(Schema $schema) | 
				
			||||
    { | 
				
			||||
        $this->addSql('DROP TABLE c_lp_category'); | 
				
			||||
        $this->addSql('ALTER TABLE c_lp DROP category_id'); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,123 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Chamilo\CourseBundle\Entity; | 
				
			||||
 | 
				
			||||
use Doctrine\ORM\Mapping as ORM; | 
				
			||||
use Gedmo\Mapping\Annotation as Gedmo; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * CLpCategory | 
				
			||||
 * | 
				
			||||
 * @ORM\Table(name="c_lp_category") | 
				
			||||
 * @ORM\Entity(repositoryClass="Gedmo\Sortable\Entity\Repository\SortableRepository") | 
				
			||||
 */ | 
				
			||||
class CLpCategory | 
				
			||||
{ | 
				
			||||
  /** | 
				
			||||
     * @var integer | 
				
			||||
     * | 
				
			||||
     * @ORM\Column(name="iid", type="integer") | 
				
			||||
     * @ORM\Id | 
				
			||||
     * @ORM\GeneratedValue(strategy="AUTO") | 
				
			||||
     */ | 
				
			||||
    private $iid; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @Gedmo\SortableGroup | 
				
			||||
     * @ORM\Column(name="c_id", type="integer") | 
				
			||||
     */ | 
				
			||||
    private $cId; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @var string | 
				
			||||
     * | 
				
			||||
     * @ORM\Column(name="name") | 
				
			||||
     */ | 
				
			||||
    private $name; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @Gedmo\SortablePosition | 
				
			||||
     * @ORM\Column(name="position", type="integer") | 
				
			||||
     */ | 
				
			||||
    private $position; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set cId | 
				
			||||
     * | 
				
			||||
     * @param integer $cId | 
				
			||||
     * @return CLpCategory | 
				
			||||
     */ | 
				
			||||
    public function setCId($cId) | 
				
			||||
    { | 
				
			||||
        $this->cId = $cId; | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get cId | 
				
			||||
     * | 
				
			||||
     * @return integer | 
				
			||||
     */ | 
				
			||||
    public function getCId() | 
				
			||||
    { | 
				
			||||
        return $this->cId; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set id | 
				
			||||
     * | 
				
			||||
     * @param integer $id | 
				
			||||
     * @return CLpCategory | 
				
			||||
     */ | 
				
			||||
    public function setId($id) | 
				
			||||
    { | 
				
			||||
        $this->iid = $id; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get blogId | 
				
			||||
     * | 
				
			||||
     * @return integer | 
				
			||||
     */ | 
				
			||||
    public function getId() | 
				
			||||
    { | 
				
			||||
        return $this->iid; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Set category name | 
				
			||||
     * | 
				
			||||
     * @param string $blogName | 
				
			||||
     * | 
				
			||||
     * @return CLpCategory | 
				
			||||
     */ | 
				
			||||
    public function setName($name) | 
				
			||||
    { | 
				
			||||
        $this->name = $name; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Get category name | 
				
			||||
     * | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getName() | 
				
			||||
    { | 
				
			||||
        return $this->name; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function setPosition($position) | 
				
			||||
    { | 
				
			||||
        $this->position = $position; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function getPosition() | 
				
			||||
    { | 
				
			||||
        return $this->position; | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue