Example #1
0
 /**
  * @param FormValidator $form
  * @param array $questionData
  * @param string $answers
  */
 public function render(FormValidator $form, $questionData = array(), $answers = '')
 {
     if (is_array($answers)) {
         $content = implode('', $answers);
     } else {
         $content = $answers;
     }
     $name = 'question' . $questionData['question_id'];
     $form->addTextarea($name, null);
     $form->setDefaults([$name => $answers]);
 }
Example #2
0
$skillList = [0 => get_lang('None')];
$gradebookList = [];
foreach ($allSkills as $skill) {
    $skillList[$skill['id']] = $skill['name'];
}
foreach ($allGradebooks as $gradebook) {
    $gradebookList[$gradebook['id']] = $gradebook['name'];
}
/* Form */
$createForm = new FormValidator('skill_create');
$createForm->addHeader(get_lang('CreateSkill'));
$createForm->addText('name', get_lang('Name'), true, ['id' => 'name']);
$createForm->addText('short_code', get_lang('ShortCode'), false, ['id' => 'short_code']);
$createForm->addSelect('parent_id', get_lang('Parent'), $skillList, ['id' => 'parent_id']);
$createForm->addSelect('gradebook_id', [get_lang('Gradebook'), get_lang('WithCertificate')], $gradebookList, ['id' => 'gradebook_id', 'multiple' => 'multiple', 'size' => 10]);
$createForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]);
$createForm->addButtonSave(get_lang('Save'));
$createForm->addHidden('id', null);
$createForm->setDefaults($formDefaultValues);
if ($createForm->validate()) {
    $created = $objSkill->add($createForm->getSubmitValues());
    if ($created) {
        Display::return_message(get_lang('TheSkillHasBeenCreated'), 'success');
    } else {
        Display::return_message(get_lang('CannotCreateSkill'), 'error');
    }
    header('Location: ' . api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php');
    exit;
}
//$tpl = new Template(get_lang('CreateSkill'));
echo $createForm->returnForm();
Example #3
0
    $extraContentForm = new FormValidator('block_extra_data', 'post', '#', null, array('id' => 'block-extra-data', 'class' => ''), FormValidator::LAYOUT_BOX_NO_LABEL);
    $extraContentFormRenderer = $extraContentForm->getDefaultRenderer();
    if ($extraContentForm->validate()) {
        $extraData = $extraContentForm->getSubmitValues();
        $extraData = array_map(['Security', 'remove_XSS'], $extraData);
        if (!empty($extraData['block'])) {
            if (!is_dir($adminExtraContentDir)) {
                mkdir($adminExtraContentDir, api_get_permissions_for_new_directories(), true);
            }
            if (!is_writable($adminExtraContentDir)) {
                die;
            }
            $fullFilePath = $adminExtraContentDir . $extraData['block'];
            $fullFilePath .= "_extra.html";
            file_put_contents($fullFilePath, $extraData['extra_content']);
            Header::location(api_get_self());
        }
    }
    $extraContentForm->addTextarea('extra_content', null, ['id' => 'extra_content']);
    $extraContentFormRenderer->setElementTemplate('<div class="form-group">{element}</div>', 'extra_content');
    $extraContentForm->addElement('hidden', 'block', null, array('id' => 'extra-block'));
    $extraContentForm->addButtonExport(get_lang('Save'), 'submit_extra_content');
    $tpl->assign('extraDataForm', $extraContentForm->returnForm());
}
// The template contains the call to the AJAX version checker
$admin_template = $tpl->get_template('admin/settings_index.tpl');
$content = $tpl->fetch($admin_template);
$tpl->assign('content', $content);
$tpl->assign('message', $message);
$tpl->display_one_col_template();
// Note: version checking mechanism has now been moved to main/inc/ajax/admin.ajax.php
Example #4
0
 /**
  * @param int $id
  * @param string $action
  *
  * @return FormValidator
  */
 public static function getCategoryForm($id, $action)
 {
     $form = new FormValidator('category', 'post', api_get_self() . '?action=' . $action . '&' . api_get_cidreq());
     $defaults = [];
     if ($action == 'addcategory') {
         $form->addHeader(get_lang('CategoryAdd'));
         $my_cat_title = get_lang('CategoryAdd');
     } else {
         $form->addHeader(get_lang('CategoryMod'));
         $my_cat_title = get_lang('CategoryMod');
         $defaults = self::getCategory($id);
     }
     $form->addHidden('id', $id);
     $form->addText('category_title', get_lang('CategoryName'));
     $form->addTextarea('description', get_lang('Description'));
     $form->addButtonSave($my_cat_title, 'submitCategory');
     $form->setDefaults($defaults);
     return $form;
 }
Example #5
0
 /**
  * Displays the form to create a new post
  * @author Toon Keppens
  *
  * @param Integer $blog_id
  */
 public static function display_new_comment_form($blog_id, $post_id, $title)
 {
     $form = new FormValidator('add_post', 'post', api_get_path(WEB_CODE_PATH) . "blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=" . intval($post_id) . "&" . api_get_cidreq(), null, array('enctype' => 'multipart/form-data'));
     $header = get_lang('AddNewComment');
     if (isset($_GET['task_id'])) {
         $header = get_lang('ExecuteThisTask');
     }
     $form->addHeader($header);
     $form->addText('title', get_lang('Title'));
     $config = array();
     if (!api_is_allowed_to_edit()) {
         $config['ToolbarSet'] = 'ProjectComment';
     } else {
         $config['ToolbarSet'] = 'ProjectCommentStudent';
     }
     $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config);
     $form->addFile('user_upload', get_lang('AddAnAttachment'));
     $form->addTextarea('post_file_comment', get_lang('FileComment'));
     $form->addHidden('action', null);
     $form->addHidden('comment_parent_id', 0);
     if (isset($_GET['task_id'])) {
         $form->addHidden('new_task_execution_submit', 'true');
         $form->addHidden('task_id', intval($_GET['task_id']));
     } else {
         $form->addHidden('new_comment_submit', 'true');
     }
     $form->addButton('save', get_lang('Save'));
     $form->display();
 }
Example #6
0
 /**
  * @param $id
  * @param array $params
  * @param string $display
  * @return string
  */
 public static function generate_invitation_form($id, $params = array())
 {
     $form = new FormValidator('send_invitation');
     $form->addTextarea('content', get_lang('AddPersonalMessage'), ['id' => 'content_invitation_id', 'rows' => 5]);
     return $form->return_form();
 }
Example #7
0
$tpl = Container::getTwig();
$load_user = 0;
if (isset($_GET['load_user'])) {
    $load_user = 1;
}
$skill_condition = '';
$tpl->addGlobal('skill_id_to_load', '');
if (isset($_GET['skill_id'])) {
    $skillId = intval($_GET['skill_id']);
    $skill_condition = '&skill_id=' . $skillId;
    $tpl->addGlobal('skill_id_to_load', $skillId);
}
$url = api_get_path(WEB_AJAX_PATH) . "skill.ajax.php?a=get_skills_tree_json&load_user={$load_user}";
$tpl->addGlobal('wheel_url', $url);
$url = api_get_path(WEB_AJAX_PATH) . 'skill.ajax.php?1=1';
$tpl->addGlobal('url', $url);
$tpl->addGlobal('isAdministration', true);
$dialogForm = new FormValidator('form', 'post', null, null, ['id' => 'add_item']);
$dialogForm->addLabel(get_lang('Name'), Display::tag('p', null, ['id' => 'name', 'class' => 'form-control-static']));
$dialogForm->addLabel(get_lang('ShortCode'), Display::tag('p', null, ['id' => 'short_code', 'class' => 'form-control-static']));
$dialogForm->addLabel(get_lang('Parent'), Display::tag('p', null, ['id' => 'parent', 'class' => 'form-control-static']));
$dialogForm->addLabel([get_lang('Gradebook'), get_lang('WithCertificate')], Display::tag('ul', null, ['id' => 'gradebook', 'class' => 'form-control-static list-unstyled']));
$dialogForm->addLabel(get_lang('Description'), Display::tag('p', null, ['id' => 'description', 'class' => 'form-control-static']));
$tpl->addGlobal('dialogForm', $dialogForm->returnForm());
$saveProfileForm = new FormValidator('form', 'post', null, null, ['id' => 'dialog-form-profile']);
$saveProfileForm->addHidden('profile_id', null);
$saveProfileForm->addText('name', get_lang('Name'), true, ['id' => 'name_profile']);
$saveProfileForm->addTextarea('description', get_lang('Description'), ['id' => 'description_profile', 'rows' => 6]);
$tpl->addGlobal('saveProfileForm', $saveProfileForm->returnForm());
echo $tpl->render('@template_style/skill/skill_wheel.html.twig');
Container::$legacyTemplate = 'layout_one_col_no_content.html.twig';
Example #8
0
 /**
  * @return string
  */
 public static function getWallForm($show_full_profile = true)
 {
     if ($show_full_profile) {
         $userId = isset($_GET['u']) ? '?u=' . intval($_GET['u']) : '';
         $form = new FormValidator('social_wall_main', 'post', api_get_path(WEB_CODE_PATH) . 'social/profile.php' . $userId, null, array('enctype' => 'multipart/form-data'), FormValidator::LAYOUT_HORIZONTAL);
         $socialWallPlaceholder = isset($_GET['u']) ? get_lang('SocialWallWriteNewPostToFriend') : get_lang('SocialWallWhatAreYouThinkingAbout');
         $form->addTextarea('social_wall_new_msg_main', null, ['placeholder' => $socialWallPlaceholder, 'cols-size' => [1, 10, 1]]);
         $form->addHidden('url_content', '');
         $form->addButtonSend(get_lang('Post'), 'wall_post_button', false, ['cols-size' => [1, 10, 1]]);
         $html = Display::panel($form->returnForm(), get_lang('SocialWall'));
         return $html;
     }
 }
Example #9
0
     api_not_allowed(true);
 }
 $interbreadcrumb[] = array('url' => api_get_self() . '?' . api_get_cidreq(), 'name' => get_lang('CustomizeIcons'));
 $toolName = $tool['name'];
 $currentUrl = api_get_self() . '?action=edit_icon&id=' . $id . '&' . api_get_cidreq();
 $form = new FormValidator('icon_edit', 'post', $currentUrl);
 $form->addHeader(get_lang('EditIcon'));
 $form->addHtml('<div class="col-md-7">');
 $form->addText('name', get_lang('Name'));
 $form->addText('link', get_lang('Links'));
 $allowed_picture_types = array('jpg', 'jpeg', 'png');
 $form->addFile('icon', get_lang('CustomIcon'));
 $form->addRule('icon', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
 $form->addSelect('target', get_lang('LinkTarget'), ['_self' => get_lang('LinkOpenSelf'), '_blank' => get_lang('LinkOpenBlank')]);
 $form->addSelect('visibility', get_lang('Visibility'), array(1 => get_lang('Visible'), 0 => get_lang('Invisible')));
 $form->addTextarea('description', get_lang('Description'), array('rows' => '3', 'cols' => '40'));
 $form->addButtonUpdate(get_lang('Update'));
 $form->addHtml('</div>');
 $form->addHtml('<div class="col-md-5">');
 if (isset($tool['custom_icon']) && !empty($tool['custom_icon'])) {
     $form->addLabel(get_lang('CurrentIcon'), Display::img(CourseHome::getCustomWebIconPath() . $tool['custom_icon']));
     $form->addCheckBox('delete_icon', null, get_lang('DeletePicture'));
 }
 $form->addHtml('</div>');
 $form->setDefaults($tool);
 $content = $form->returnForm();
 if ($form->validate()) {
     $data = $form->getSubmitValues();
     CourseHome::updateTool($id, $data);
     Display::addFlash(Display::return_message(get_lang('Updated')));
     if (isset($data['delete_icon'])) {
Example #10
0
 /**
  * @return string
  */
 public static function getWallForm()
 {
     $form = new FormValidator('social_wall_main', 'post', api_get_path(WEB_CODE_PATH) . 'social/profile.php', null, array('enctype' => 'multipart/form-data'), FormValidator::LAYOUT_HORIZONTAL);
     $form->addTextarea('social_wall_new_msg_main', null, ['placeholder' => get_lang('SocialWallWhatAreYouThinkingAbout'), 'cols-size' => [1, 10, 1]]);
     $form->addHidden('url_content', '');
     $form->addButtonSend(get_lang('Post'), 'wall_post_button', false, ['cols-size' => [1, 10, 1]]);
     $html = Display::panel($form->returnForm(), get_lang('SocialWall'));
     return $html;
 }
Example #11
0
    header('Location: ' . api_get_path(WEB_PATH));
    exit;
}
$currentUserId = api_get_user_id();
$currentUser = $entityManager->find('ChamiloUserBundle:User', $currentUserId);
$allowExport = $currentUser ? $currentUser->getId() === $skillIssue->getUser()->getId() : false;
$allowComment = $currentUser ? Skill::userCanAddFeedbackToUser($currentUser, $skillIssue->getUser()) : false;
$skillIssueDate = api_get_local_time($skillIssue->getAcquiredSkillAt());
$skillIssueInfo = ['id' => $skillIssue->getId(), 'datetime' => api_format_date($skillIssueDate, DATE_TIME_FORMAT_SHORT), 'argumentation' => $skillIssue->getArgumentation(), 'source_name' => $skillIssue->getSourceName(), 'user_id' => $skillIssue->getUser()->getId(), 'user_complete_name' => $skillIssue->getUser()->getCompleteName(), 'skill_badge_image' => $skillIssue->getSkill()->getWebIconPath(), 'skill_name' => $skillIssue->getSkill()->getName(), 'skill_short_code' => $skillIssue->getSkill()->getShortCode(), 'skill_description' => $skillIssue->getSkill()->getDescription(), 'skill_criteria' => $skillIssue->getSkill()->getCriteria(), 'badge_asserion' => [$skillIssue->getAssertionUrl()], 'comments' => [], 'feedback_average' => $skillIssue->getAverage()];
$skillIssueComments = $skillIssue->getComments(true);
foreach ($skillIssueComments as $comment) {
    $commentDate = api_get_local_time($comment->getFeedbackDateTime());
    $skillIssueInfo['comments'][] = ['text' => $comment->getFeedbackText(), 'value' => $comment->getFeedbackValue(), 'giver_complete_name' => $comment->getFeedbackGiver()->getCompleteName(), 'datetime' => api_format_date($commentDate, DATE_TIME_FORMAT_SHORT)];
}
$form = new FormValidator('comment');
$form->addTextarea('comment', get_lang('NewComment'), ['rows' => 4]);
$form->applyFilter('comment', 'trim');
$form->addRule('comment', get_lang('ThisFieldIsRequired'), 'required');
$form->addSelect('value', [get_lang('Value'), get_lang('RateTheSkillInPractice')], ['-', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
$form->addHidden('user', $skillIssue->getUser()->getId());
$form->addHidden('issue', $skillIssue->getId());
$form->addButtonSend(get_lang('Send'));
if ($form->validate() && $allowComment) {
    $values = $form->exportValues();
    $skillUserComment = new Chamilo\CoreBundle\Entity\SkillRelUserComment();
    $skillUserComment->setFeedbackDateTime(new DateTime())->setFeedbackGiver($currentUser)->setFeedbackText($values['comment'])->setFeedbackValue($values['value'] ? $values['value'] : null)->setSkillRelUser($skillIssue);
    $entityManager->persist($skillUserComment);
    $entityManager->flush();
    header("Location: " . $skillIssue->getIssueUrl());
    exit;
}
Example #12
0
 /**
  * @return string
  */
 public static function getWallForm()
 {
     $form = new FormValidator('social_wall_main', 'post', api_get_path(WEB_CODE_PATH) . 'social/profile.php', null, array('enctype' => 'multipart/form-data'));
     $form->addTextarea('social_wall_new_msg_main', null, ['placeholder' => get_lang('SocialWallWhatAreYouThinkingAbout'), 'style' => 'width : 100%']);
     $form->addHtml('<div class="form-group "><div class="url_preview col-md-9 panel-body"></div></div>');
     $form->addButtonSend(get_lang('Post'));
     $form->addHidden('url_content', '');
     $html = Display::panel($form->returnForm(), get_lang('SocialWall'));
     return $html;
 }
Example #13
0
/* See license terms in /license.txt */
/**
 * This script is a configuration file for the date plugin.
 * You can use it as a master for other platform plugins (course plugins are slightly different).
 * These settings will be used in the administration interface for plugins (Chamilo configuration settings->Plugins)
 * @package chamilo.plugin
 * @author Julio Montoya <*****@*****.**>
 */
/* Plugin config */
//the plugin title
$plugin_info['title'] = 'Text';
//the comments that go with the plugin
$plugin_info['comment'] = "Displays a text message";
//the plugin version
$plugin_info['version'] = '1.0';
//the plugin author
$plugin_info['author'] = 'Julio Montoya';
/* Plugin optional settings */
$form = new FormValidator('text_form');
$form->addTextarea('content', get_lang('Content'));
$form->addButtonSave(get_lang('Save'), 'submit_button');
$content = '';
$setting = api_get_setting('text_content');
if (!empty($setting) && is_array($setting)) {
    if (isset($setting['text'])) {
        $content = $setting['text'];
    }
}
$form->setDefaults(array('content' => $content));
$plugin_info['settings_form'] = $form;
Example #14
0
if (!$user) {
    Display::addFlash(Display::return_message(get_lang('NoUser'), 'error'));
    header('Location: ' . api_get_path(WEB_PATH));
    exit;
}
$skills = $skillRepo->findBy(['status' => Skill::STATUS_ENABLED]);
$skillsOptions = [];
foreach ($skills as $skill) {
    $skillsOptions[$skill->getId()] = $skill->getName();
}
$form = new FormValidator('assign_skill');
$form->addText('user_name', get_lang('UserName'), false);
$form->addSelect('skill', get_lang('Skill'), $skillsOptions);
$form->addHidden('user', $user->getId());
$form->addRule('skill', get_lang('ThisFieldIsRequired'), 'required');
$form->addTextarea('argumentation', get_lang('Argumentation'), ['rows' => 6]);
$form->applyFilter('argumentation', 'trim');
$form->addRule('argumentation', get_lang('ThisFieldIsRequired'), 'required');
$form->addButtonSave(get_lang('Save'));
if ($form->validate()) {
    $values = $form->exportValues();
    $skill = $skillRepo->find($values['skill']);
    if (!$skill) {
        Display::addFlash(Display::return_message(get_lang('SkillNotFound'), 'error'));
        header('Location: ' . api_get_self() . '?' . http_build_query(['user' => $user->getId()]));
        exit;
    }
    if ($user->hasSkill($skill)) {
        Display::addFlash(Display::return_message(sprintf(get_lang('TheUserXHasAlreadyAchievedTheSkillY'), $user->getCompleteName(), $skill->getName()), 'warning'));
        header('Location: ' . api_get_self() . '?' . http_build_query(['user' => $user->getId()]));
        exit;
Example #15
0
 /**
  * @return string
  */
 public static function getWallForm()
 {
     $form = new FormValidator('social_wall_main', 'post', api_get_path(WEB_CODE_PATH) . 'social/profile.php', null, array('enctype' => 'multipart/form-data'));
     $form->addTextarea('social_wall_new_msg_main', null, array('placeholder' => get_lang('SocialWallWhatAreYouThinkingAbout')));
     $form->addButtonSend(get_lang('Post'));
     $html = Display::panel($form->returnForm(), get_lang('SocialWall'));
     return $html;
 }