Fixing advmultiselect form icons see BT#5768

skala
Julio Montoya 13 years ago
parent 4ac57a8df5
commit bd19ed2d8e
  1. 284
      main/group/group_edit.php
  2. 11
      main/inc/lib/pear/HTML/QuickForm/advanced_settings.php
  3. 583
      main/inc/lib/pear/HTML/QuickForm/advmultiselect.php
  4. 20
      main/inc/lib/pear/HTML/QuickForm/label.php
  5. 75
      main/survey/survey_invite.php

@ -27,12 +27,12 @@ $group_id = api_get_group_id();
$current_group = GroupManager :: get_group_properties($group_id); $current_group = GroupManager :: get_group_properties($group_id);
$nameTools = get_lang('EditGroup'); $nameTools = get_lang('EditGroup');
$interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups')); $interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ('url' => 'group_space.php?'.api_get_cidReq(), 'name' => $current_group['name']); $interbreadcrumb[] = array('url' => 'group_space.php?'.api_get_cidReq(), 'name' => $current_group['name']);
$is_group_member = GroupManager :: is_tutor_of_group(api_get_user_id(), $group_id); $is_group_member = GroupManager :: is_tutor_of_group(api_get_user_id(), $group_id);
if (!api_is_allowed_to_edit(false,true) && !$is_group_member) { if (!api_is_allowed_to_edit(false, true) && !$is_group_member) {
api_not_allowed(true); api_not_allowed(true);
} }
@ -41,8 +41,13 @@ if (!api_is_allowed_to_edit(false,true) && !$is_group_member) {
/** /**
* List all users registered to the course * List all users registered to the course
*/ */
function search_members_keyword($firstname, $lastname, $username, $official_code, $keyword) { function search_members_keyword($firstname, $lastname, $username, $official_code, $keyword)
if (api_strripos($firstname, $keyword) !== false || api_strripos($lastname, $keyword) !== false || api_strripos($username, $keyword) !== false || api_strripos($official_code, $keyword) !== false) { {
if (api_strripos($firstname, $keyword) !== false || api_strripos($lastname, $keyword) !== false || api_strripos(
$username,
$keyword
) !== false || api_strripos($official_code, $keyword) !== false
) {
return true; return true;
} else { } else {
return false; return false;
@ -53,7 +58,8 @@ function search_members_keyword($firstname, $lastname, $username, $official_code
/** /**
* function to sort users after getting the list in the db. Necessary because there are 2 or 3 queries. Called by usort() * function to sort users after getting the list in the db. Necessary because there are 2 or 3 queries. Called by usort()
*/ */
function sort_users($user_a, $user_b) { function sort_users($user_a, $user_b)
{
if (api_sort_by_first_name()) { if (api_sort_by_first_name()) {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']); $cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
if ($cmp !== 0) { if ($cmp !== 0) {
@ -84,7 +90,8 @@ function sort_users($user_a, $user_b) {
/** /**
* Function to check the given max number of members per group * Function to check the given max number of members per group
*/ */
function check_max_number_of_members($value) { function check_max_number_of_members($value)
{
$max_member_no_limit = $value['max_member_no_limit']; $max_member_no_limit = $value['max_member_no_limit'];
if ($max_member_no_limit == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { if ($max_member_no_limit == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
return true; return true;
@ -96,12 +103,16 @@ function check_max_number_of_members($value) {
/** /**
* Function to check if the number of selected group members is valid * Function to check if the number of selected group members is valid
*/ */
function check_group_members($value) { function check_group_members($value)
{
if ($value['max_member_no_limit'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { if ($value['max_member_no_limit'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
return true; return true;
} }
if (isset($value['max_member']) && isset($value['group_members']) && $value['max_member'] < count($value['group_members'])) { if (isset($value['max_member']) && isset($value['group_members']) && $value['max_member'] < count(
return array ('group_members' => get_lang('GroupTooMuchMembers')); $value['group_members']
)
) {
return array('group_members' => get_lang('GroupTooMuchMembers'));
} }
return true; return true;
} }
@ -127,14 +138,17 @@ $form->addElement('hidden', 'referer');
$form->add_textfield('name', get_lang('GroupName')); $form->add_textfield('name', get_lang('GroupName'));
// Description // Description
$form->addElement('textarea', 'description', get_lang('Description'), array ('class' => 'span6', 'rows' => 6)); $form->addElement('textarea', 'description', get_lang('Description'), array('class' => 'span6', 'rows' => 6));
$complete_user_list = GroupManager :: fill_groups_list($current_group['id']); $complete_user_list = GroupManager :: fill_groups_list($current_group['id']);
usort($complete_user_list, 'sort_users'); usort($complete_user_list, 'sort_users');
$possible_users = array(); $possible_users = array();
foreach ($complete_user_list as $index => $user) { foreach ($complete_user_list as $index => $user) {
$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')'; $possible_users[$user['user_id']] = api_get_person_name(
$user['firstname'],
$user['lastname']
).' ('.$user['username'].')';
} }
// Group tutors // Group tutors
@ -145,27 +159,14 @@ foreach ($group_tutor_list as $index => $user) {
$selected_tutors[] = $user['user_id']; $selected_tutors[] = $user['user_id'];
} }
$group_tutors_element = $form->addElement('advmultiselect', 'group_tutors', get_lang('GroupTutors'), $possible_users, 'style="width: 280px;"'); $group_tutors_element = $form->addElement('advmultiselect', 'group_tutors', get_lang('GroupTutors'), $possible_users);
$group_tutors_element->setElementTemplate(' $group_tutors_element->setButtonAttributes('add');
{javascript} $group_tutors_element->setButtonAttributes('remove');
<table{class}>
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
<td valign="top">{unselected}</td>
<td align="center">{add}<br /><br />{remove}</td>
<td valign="top">{selected}</td>
</tr>
</table>
');
$group_tutors_element->setButtonAttributes('add', array('class' => 'btn arrowr'));
$group_tutors_element->setButtonAttributes('remove', array('class' => 'btn arrowl'));
// Group members // Group members
$group_member_list = GroupManager :: get_subscribed_users($current_group['id']); $group_member_list = GroupManager :: get_subscribed_users($current_group['id']);
$selected_users = array (); $selected_users = array();
foreach ($group_member_list as $index => $user) { foreach ($group_member_list as $index => $user) {
$selected_users[] = $user['user_id']; $selected_users[] = $user['user_id'];
} }
@ -173,33 +174,41 @@ foreach ($group_member_list as $index => $user) {
// possible : number_groups_left > 0 and is group member // possible : number_groups_left > 0 and is group member
$possible_users = array(); $possible_users = array();
foreach ($complete_user_list as $index => $user) { foreach ($complete_user_list as $index => $user) {
if ($user['number_groups_left'] > 0 || in_array($user['user_id'], $selected_users) ) { if ($user['number_groups_left'] > 0 || in_array($user['user_id'], $selected_users)) {
$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')'; $possible_users[$user['user_id']] = api_get_person_name(
$user['firstname'],
$user['lastname']
).' ('.$user['username'].')';
} }
} }
$group_members_element = $form->addElement('advmultiselect', 'group_members', get_lang('GroupMembers'), $possible_users, 'style="width: 280px;"'); $group_members_element = $form->addElement(
'advmultiselect',
$group_members_element->setElementTemplate(' 'group_members',
{javascript} get_lang('GroupMembers'),
<table{class}> $possible_users
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 --> );
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 --> $group_members_element->setButtonAttributes('add');
<tr> $group_members_element->setButtonAttributes('remove');
<td valign="top">{unselected}</td>
<td align="center">{add}<br /><br />{remove}</td>
<td valign="top">{selected}</td>
</tr>
</table>');
$group_members_element->setButtonAttributes('add', array('class' => 'btn arrowr'));
$group_members_element->setButtonAttributes('remove', array('class' => 'btn arrowl'));
$form->addFormRule('check_group_members'); $form->addFormRule('check_group_members');
// Members per group // Members per group
$form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'), GroupManager::MEMBER_PER_GROUP_NO_LIMIT); $form->addElement(
'radio',
'max_member_no_limit',
get_lang('GroupLimit'),
get_lang('NoLimit'),
GroupManager::MEMBER_PER_GROUP_NO_LIMIT
);
$group = array(); $group = array();
$group[] = $form->createElement('radio', 'max_member_no_limit', null, get_lang('MaximumOfParticipants'), 1, array('id' => 'max_member_selected')); $group[] = $form->createElement(
'radio',
'max_member_no_limit',
null,
get_lang('MaximumOfParticipants'),
1,
array('id' => 'max_member_selected')
);
$group[] = $form->createElement('text', 'max_member', null, array('class' => 'span1', 'id' => 'max_member')); $group[] = $form->createElement('text', 'max_member', null, array('class' => 'span1', 'id' => 'max_member'));
$group[] = $form->createElement('static', null, null, get_lang('GroupPlacesThis')); $group[] = $form->createElement('static', null, null, get_lang('GroupPlacesThis'));
$form->addGroup($group, 'max_member_group', null, '', false); $form->addGroup($group, 'max_member_group', null, '', false);
@ -207,58 +216,168 @@ $form->addRule('max_member_group', get_lang('InvalidMaxNumberOfMembers'), 'callb
// Self registration // Self registration
$group = array(); $group = array();
$group[] = $form->createElement('checkbox', 'self_registration_allowed', get_lang('GroupSelfRegistration'), get_lang('GroupAllowStudentRegistration'), 1); $group[] = $form->createElement(
$group[] = $form->createElement('checkbox', 'self_unregistration_allowed', null, get_lang('GroupAllowStudentUnregistration'), 1); 'checkbox',
$form->addGroup($group, '', Display::return_icon('user.png', get_lang('GroupSelfRegistration') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupSelfRegistration'), '', false); 'self_registration_allowed',
get_lang('GroupSelfRegistration'),
get_lang('GroupAllowStudentRegistration'),
1
);
$group[] = $form->createElement(
'checkbox',
'self_unregistration_allowed',
null,
get_lang('GroupAllowStudentUnregistration'),
1
);
$form->addGroup(
$group,
'',
Display::return_icon('user.png', get_lang('GroupSelfRegistration'), array(), ICON_SIZE_SMALL).' '.get_lang(
'GroupSelfRegistration'
),
'',
false
);
// Documents settings // Documents settings
$group = array(); $group = array();
$group[] = $form->createElement('radio', 'doc_state', get_lang('GroupDocument'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); $group[] = $form->createElement(
'radio',
'doc_state',
get_lang('GroupDocument'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'doc_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); $group[] = $form->createElement('radio', 'doc_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'doc_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $group[] = $form->createElement('radio', 'doc_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('folder.png', get_lang('GroupDocument') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupDocument'), '', false); $form->addGroup(
$group,
'',
Display::return_icon('folder.png', get_lang('GroupDocument'), array(), ICON_SIZE_SMALL).' '.get_lang(
'GroupDocument'
),
'',
false
);
// Work settings // Work settings
$group = array(); $group = array();
$group[] = $form->createElement('radio', 'work_state', get_lang('GroupWork'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); $group[] = $form->createElement(
'radio',
'work_state',
get_lang('GroupWork'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'work_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); $group[] = $form->createElement('radio', 'work_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'work_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $group[] = $form->createElement('radio', 'work_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('work.png', get_lang('GroupWork') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupWork'), '', false); $form->addGroup(
$group,
'',
Display::return_icon('work.png', get_lang('GroupWork'), array(), ICON_SIZE_SMALL).' '.get_lang('GroupWork'),
'',
false
);
// Calendar settings // Calendar settings
$group = array(); $group = array();
$group[] = $form->createElement('radio', 'calendar_state', get_lang('GroupCalendar'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); $group[] = $form->createElement(
'radio',
'calendar_state',
get_lang('GroupCalendar'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'calendar_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); $group[] = $form->createElement('radio', 'calendar_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'calendar_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $group[] = $form->createElement('radio', 'calendar_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('agenda.png', get_lang('GroupCalendar') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupCalendar'), '', false); $form->addGroup(
$group,
'',
Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), ICON_SIZE_SMALL).' '.get_lang(
'GroupCalendar'
),
'',
false
);
// Announcements settings // Announcements settings
$group = array(); $group = array();
$group[] = $form->createElement('radio', 'announcements_state', get_lang('GroupAnnouncements'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); $group[] = $form->createElement(
'radio',
'announcements_state',
get_lang('GroupAnnouncements'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'announcements_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); $group[] = $form->createElement('radio', 'announcements_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'announcements_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $group[] = $form->createElement('radio', 'announcements_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('announce.png', get_lang('GroupAnnouncements') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupAnnouncements'), '', false); $form->addGroup(
$group,
'',
Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), ICON_SIZE_SMALL).' '.get_lang(
'GroupAnnouncements'
),
'',
false
);
//Forum settings //Forum settings
$group = array(); $group = array();
$group[] = $form->createElement('radio', 'forum_state', get_lang('GroupForum'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); $group[] = $form->createElement(
'radio',
'forum_state',
get_lang('GroupForum'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'forum_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); $group[] = $form->createElement('radio', 'forum_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'forum_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $group[] = $form->createElement('radio', 'forum_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('forum.png', get_lang('GroupForum') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupForum'), '', false); $form->addGroup(
$group,
'',
Display::return_icon('forum.png', get_lang('GroupForum'), array(), ICON_SIZE_SMALL).' '.get_lang('GroupForum'),
'',
false
);
// Wiki settings // Wiki settings
$group = array(); $group = array();
$group[] = $form->createElement('radio', 'wiki_state', get_lang('GroupWiki'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); $group[] = $form->createElement(
'radio',
'wiki_state',
get_lang('GroupWiki'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'wiki_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); $group[] = $form->createElement('radio', 'wiki_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'wiki_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $group[] = $form->createElement('radio', 'wiki_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('wiki.png', get_lang('GroupWiki') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupWiki'), '', false); $form->addGroup(
$group,
'',
Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), ICON_SIZE_SMALL).' '.get_lang('GroupWiki'),
'',
false
);
// Chat settings // Chat settings
$group = array(); $group = array();
$group[] = $form->createElement('radio', 'chat_state', get_lang('Chat'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); $group[] = $form->createElement(
'radio',
'chat_state',
get_lang('Chat'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'chat_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); $group[] = $form->createElement('radio', 'chat_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'chat_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $group[] = $form->createElement('radio', 'chat_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('chat.png', get_lang('Chat') , array(), ICON_SIZE_SMALL).' '.get_lang('Chat'), '', false); $form->addGroup(
$group,
'',
Display::return_icon('chat.png', get_lang('Chat'), array(), ICON_SIZE_SMALL).' '.get_lang('Chat'),
'',
false
);
// submit button // submit button
$form->addElement('style_submit_button', 'submit', get_lang('PropModify'), 'class="save"'); $form->addElement('style_submit_button', 'submit', get_lang('PropModify'), 'class="save"');
@ -272,7 +391,21 @@ if ($form->validate()) {
} }
$self_registration_allowed = isset($values['self_registration_allowed']) ? 1 : 0; $self_registration_allowed = isset($values['self_registration_allowed']) ? 1 : 0;
$self_unregistration_allowed = isset($values['self_unregistration_allowed']) ? 1 : 0; $self_unregistration_allowed = isset($values['self_unregistration_allowed']) ? 1 : 0;
GroupManager :: set_group_properties($current_group['id'], strip_tags($values['name']), strip_tags($values['description']), $max_member, $values['doc_state'], $values['work_state'], $values['calendar_state'], $values['announcements_state'], $values['forum_state'], $values['wiki_state'], $values['chat_state'], $self_registration_allowed, $self_unregistration_allowed); GroupManager :: set_group_properties(
$current_group['id'],
strip_tags($values['name']),
strip_tags($values['description']),
$max_member,
$values['doc_state'],
$values['work_state'],
$values['calendar_state'],
$values['announcements_state'],
$values['forum_state'],
$values['wiki_state'],
$values['chat_state'],
$self_registration_allowed,
$self_unregistration_allowed
);
// Storing the tutors (we first remove all the tutors and then add only those who were selected) // Storing the tutors (we first remove all the tutors and then add only those who were selected)
GroupManager :: unsubscribe_all_tutors($current_group['id']); GroupManager :: unsubscribe_all_tutors($current_group['id']);
@ -288,10 +421,21 @@ if ($form->validate()) {
// Returning to the group area (note: this is inconsistent with the rest of chamilo) // Returning to the group area (note: this is inconsistent with the rest of chamilo)
$cat = GroupManager :: get_category_from_group($current_group['id']); $cat = GroupManager :: get_category_from_group($current_group['id']);
if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { if (isset($_POST['group_members']) && count(
header('Location: group.php?'.api_get_cidreq(true, false).'&action=warning_message&msg='.get_lang('GroupTooMuchMembers')); $_POST['group_members']
) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT
) {
header(
'Location: group.php?'.api_get_cidreq(true, false).'&action=warning_message&msg='.get_lang(
'GroupTooMuchMembers'
)
);
} else { } else {
header('Location: group.php?'.api_get_cidreq(true, false).'&action=success_message&msg='.get_lang('GroupSettingsModified').'&category='.$cat['id']); header(
'Location: group.php?'.api_get_cidreq(true, false).'&action=success_message&msg='.get_lang(
'GroupSettingsModified'
).'&category='.$cat['id']
);
} }
exit; exit;
} }

@ -42,14 +42,15 @@ class HTML_QuickForm_advanced_settings extends HTML_QuickForm_static
* @access public * @access public
* @return void * @return void
*/ */
function accept(&$renderer, $required=false, $error=null) function accept(&$renderer, $required = false, $error = null)
{ {
$renderer->renderHtml($this); $renderer->renderHtml($this);
} // end func accept } // end func accept
function toHtml() { function toHtml()
return '<div class="control-group "> {
return '<div class="control-group">
<label class="control-label"></label> <label class="control-label"></label>
<div class="controls"> <div class="controls">
'.HTML_QuickForm_static::toHtml().' '.HTML_QuickForm_static::toHtml().'
@ -57,5 +58,5 @@ class HTML_QuickForm_advanced_settings extends HTML_QuickForm_static
</div> </div>
'; ';
} //end func toHtml }
} //end class HTML_QuickForm_html }

@ -274,14 +274,21 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
* @return void * @return void
* @since version 0.4.0 (2005-06-25) * @since version 0.4.0 (2005-06-25)
*/ */
function HTML_QuickForm_advmultiselect($elementName = null, $elementLabel = null, function HTML_QuickForm_advmultiselect(
$options = null, $attributes = null, $elementName = null,
$sort = null) $elementLabel = null,
{ $options = null,
$attributes = null,
$sort = null
) {
$opts = $options; $opts = $options;
$options = null; // prevent to use the default select element load options $options = null; // prevent to use the default select element load options
$this->HTML_QuickForm_select($elementName, $elementLabel, $this->HTML_QuickForm_select(
$options, $attributes); $elementName,
$elementLabel,
$options,
$attributes
);
// allow to load options at once and take care of fancy attributes // allow to load options at once and take care of fancy attributes
$this->load($opts); $this->load($opts);
@ -295,17 +302,17 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
} }
if (is_null($this->getAttribute('style'))) { if (is_null($this->getAttribute('style'))) {
// default width of each select box // default width of each select box
$this->updateAttributes(array('style' => 'width:100px;')); //$this->updateAttributes(array('style' => 'min-width:100px;'));
} }
$this->_tableAttributes = $this->getAttribute('class'); $this->_tableAttributes = $this->getAttribute('class');
if (is_null($this->_tableAttributes)) { if (is_null($this->_tableAttributes)) {
// default table layout $this->updateAttributes(array('class' => 'span4'));
$attr = array('border' => '0',
'cellpadding' => '10', 'cellspacing' => '0');
} else { } else {
$attr = array('class' => $this->_tableAttributes); $attr = array('class' => $this->_tableAttributes);
$this->_removeAttr('class', $this->_attributes); $this->_removeAttr('class', $this->_attributes);
} }
$this->_tableAttributes = $this->_getAttrString($attr); $this->_tableAttributes = $this->_getAttrString($attr);
// set default add button attributes // set default add button attributes
@ -395,117 +402,158 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
function setButtonAttributes($button, $attributes = null) function setButtonAttributes($button, $attributes = null)
{ {
if (!is_string($button)) { if (!is_string($button)) {
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' . return PEAR::throwError(
'Argument 1 of HTML_QuickForm_advmultiselect::'.
'setButtonAttributes is not a string', 'setButtonAttributes is not a string',
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
array('level' => 'exception')); array('level' => 'exception')
);
} }
switch ($button) { switch ($button) {
case 'add': case 'add':
if (is_null($attributes)) { if (is_null($attributes)) {
$this->_addButtonAttributes $this->_addButtonAttributes
= array('name' => 'add', = array(
'value' => ' ', 'name' => 'add',
'type' => 'button'); 'value' => '',
'type' => 'button'
);
$this->setValue('<i class="icon-shopping-cart icon-large"></i>');
} else { } else {
$this->_updateAttrArray($this->_addButtonAttributes, $this->_updateAttrArray(
$this->_parseAttributes($attributes)); $this->_addButtonAttributes,
$this->_parseAttributes($attributes)
);
} }
break; break;
case 'remove': case 'remove':
if (is_null($attributes)) { if (is_null($attributes)) {
$this->_removeButtonAttributes $this->_removeButtonAttributes
= array('name' => 'remove', = array(
'name' => 'remove',
'value' => ' ', 'value' => ' ',
'type' => 'button'); 'type' => 'button'
);
} else { } else {
$this->_updateAttrArray($this->_removeButtonAttributes, $this->_updateAttrArray(
$this->_parseAttributes($attributes)); $this->_removeButtonAttributes,
$this->_parseAttributes($attributes)
);
} }
break; break;
case 'all': case 'all':
if (is_null($attributes)) { if (is_null($attributes)) {
$this->_allButtonAttributes $this->_allButtonAttributes
= array('name' => 'all', = array(
'name' => 'all',
'value' => ' Select All ', 'value' => ' Select All ',
'type' => 'button'); 'type' => 'button'
);
} else { } else {
$this->_updateAttrArray($this->_allButtonAttributes, $this->_updateAttrArray(
$this->_parseAttributes($attributes)); $this->_allButtonAttributes,
$this->_parseAttributes($attributes)
);
} }
break; break;
case 'none': case 'none':
if (is_null($attributes)) { if (is_null($attributes)) {
$this->_noneButtonAttributes $this->_noneButtonAttributes
= array('name' => 'none', = array(
'name' => 'none',
'value' => ' Select None ', 'value' => ' Select None ',
'type' => 'button'); 'type' => 'button'
);
} else { } else {
$this->_updateAttrArray($this->_noneButtonAttributes, $this->_updateAttrArray(
$this->_parseAttributes($attributes)); $this->_noneButtonAttributes,
$this->_parseAttributes($attributes)
);
} }
break; break;
case 'toggle': case 'toggle':
if (is_null($attributes)) { if (is_null($attributes)) {
$this->_toggleButtonAttributes $this->_toggleButtonAttributes
= array('name' => 'toggle', = array(
'name' => 'toggle',
'value' => ' Toggle Selection ', 'value' => ' Toggle Selection ',
'type' => 'button'); 'type' => 'button'
);
} else { } else {
$this->_updateAttrArray($this->_toggleButtonAttributes, $this->_updateAttrArray(
$this->_parseAttributes($attributes)); $this->_toggleButtonAttributes,
$this->_parseAttributes($attributes)
);
} }
break; break;
case 'moveup': case 'moveup':
if (is_null($attributes)) { if (is_null($attributes)) {
$this->_upButtonAttributes $this->_upButtonAttributes
= array('name' => 'up', = array(
'name' => 'up',
'value' => ' Up ', 'value' => ' Up ',
'type' => 'button'); 'type' => 'button'
);
} else { } else {
$this->_updateAttrArray($this->_upButtonAttributes, $this->_updateAttrArray(
$this->_parseAttributes($attributes)); $this->_upButtonAttributes,
$this->_parseAttributes($attributes)
);
} }
break; break;
case 'movedown': case 'movedown':
if (is_null($attributes)) { if (is_null($attributes)) {
$this->_downButtonAttributes $this->_downButtonAttributes
= array('name' => 'down', = array(
'name' => 'down',
'value' => ' Down ', 'value' => ' Down ',
'type' => 'button'); 'type' => 'button'
);
} else { } else {
$this->_updateAttrArray($this->_downButtonAttributes, $this->_updateAttrArray(
$this->_parseAttributes($attributes)); $this->_downButtonAttributes,
$this->_parseAttributes($attributes)
);
} }
break; break;
case 'movetop': case 'movetop':
if (is_null($attributes)) { if (is_null($attributes)) {
$this->_topButtonAttributes $this->_topButtonAttributes
= array('name' => 'top', = array(
'name' => 'top',
'value' => ' Top ', 'value' => ' Top ',
'type' => 'button'); 'type' => 'button'
);
} else { } else {
$this->_updateAttrArray($this->_topButtonAttributes, $this->_updateAttrArray(
$this->_parseAttributes($attributes)); $this->_topButtonAttributes,
$this->_parseAttributes($attributes)
);
} }
break; break;
case 'movebottom': case 'movebottom':
if (is_null($attributes)) { if (is_null($attributes)) {
$this->_bottomButtonAttributes $this->_bottomButtonAttributes
= array('name' => 'bottom', = array(
'name' => 'bottom',
'value' => ' Bottom ', 'value' => ' Bottom ',
'type' => 'button'); 'type' => 'button'
);
} else { } else {
$this->_updateAttrArray($this->_bottomButtonAttributes, $this->_updateAttrArray(
$this->_parseAttributes($attributes)); $this->_bottomButtonAttributes,
$this->_parseAttributes($attributes)
);
} }
break; break;
default; default;
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' . return PEAR::throwError(
'Argument 1 of HTML_QuickForm_advmultiselect::'.
'setButtonAttributes has unexpected value', 'setButtonAttributes has unexpected value',
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
array('level' => 'error')); array('level' => 'error')
);
} }
} }
@ -524,26 +572,24 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$oldTemplate = $this->_elementTemplate; $oldTemplate = $this->_elementTemplate;
if (isset($html) && is_string($html)) { if (isset($html) && is_string($html)) {
$this->_elementTemplate = $html; // $this->_elementTemplate = $html;
} else { } else {
/*<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->*/
$this->_elementTemplate = ' $this->_elementTemplate = '
{javascript} {javascript}
<table{class}> <div class="advmultiselect row">
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 --> <div class="span4">{unselected}</div>
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 --> <div class="span1">{add} <br /><br />{remove}</div>
<tr> <div class="span4">{selected}</div>
<td valign="top">{unselected}</td> </div>
<td align="center">{add}{remove}</td> ';
<td valign="top">{selected}</td>
</tr>
</table>
';
} }
if ($js == false) { if ($js == false) {
$this->_elementTemplate = str_replace('{javascript}', '', $this->_elementTemplate = str_replace('{javascript}', '', $this->_elementTemplate);
$this->_elementTemplate);
} }
return $oldTemplate; //return $oldTemplate;
} }
/** /**
@ -571,14 +617,14 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$css = str_replace('{id}', $id, $this->_elementCSS); $css = str_replace('{id}', $id, $this->_elementCSS);
if ($raw !== true) { if ($raw !== true) {
$css = '<style type="text/css">' . PHP_EOL $css = '<style type="text/css">'.PHP_EOL
// Modified by Chamilo team, 16-MAR-2010. // Modified by Chamilo team, 16-MAR-2010.
//. '<!--' . $css . '// -->' . PHP_EOL //. '<!--' . $css . '// -->' . PHP_EOL
. '/*<![CDATA[*/' . PHP_EOL .'/*<![CDATA[*/'.PHP_EOL
. $css . PHP_EOL .$css.PHP_EOL
. '/*]]>*/' . PHP_EOL .'/*]]>*/'.PHP_EOL
// //
. '</style>'; .'</style>';
} }
return $css; return $css;
} }
@ -599,10 +645,11 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$tabs = $this->_getTabs(); $tabs = $this->_getTabs();
$tab = $this->_getTab(); $tab = $this->_getTab();
$selectId = $this->getName(); $selectId = $this->getName();
$selectName = $this->getName() . '[]'; $selectName = $this->getName().'[]';
$selectNameFrom = $this->getName() . '-f[]'; $selectNameFrom = $this->getName().'-f[]';
$selectNameTo = $this->getName() . '-t[]'; $selectNameTo = $this->getName().'-t[]';
$selected_count = 0; $selected_count = 0;
// placeholder {unselected} existence determines if we will render // placeholder {unselected} existence determines if we will render
@ -612,14 +659,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$id = $this->getAttribute('name'); $id = $this->getAttribute('name');
$strHtmlSelected = $tab . '<div id="qfams_'.$id.'">' . PHP_EOL; $strHtmlSelected = $tab.'<div id="qfams_'.$id.'">'.PHP_EOL;
$unselected_count = count($this->_options); $unselected_count = count($this->_options);
$checkbox_id_suffix = 0; $checkbox_id_suffix = 0;
foreach ($this->_options as $option) { foreach ($this->_options as $option) {
$_labelAttributes $_labelAttributes = array('style', 'class', 'onmouseover', 'onmouseout');
= array('style', 'class', 'onmouseover', 'onmouseout');
$labelAttributes = array(); $labelAttributes = array();
foreach ($_labelAttributes as $attr) { foreach ($_labelAttributes as $attr) {
if (isset($option['attr'][$attr])) { if (isset($option['attr'][$attr])) {
@ -629,7 +675,8 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
} }
if (is_array($this->_values) if (is_array($this->_values)
&& in_array((string)$option['attr']['value'], $this->_values)) { && in_array((string)$option['attr']['value'], $this->_values)
) {
// The items is *selected* // The items is *selected*
$checked = ' checked="checked"'; $checked = ' checked="checked"';
$selected_count++; $selected_count++;
@ -639,17 +686,17 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
} }
$checkbox_id_suffix++; $checkbox_id_suffix++;
$strHtmlSelected .= $tab $strHtmlSelected .= $tab
. '<label' .'<label'
. $this->_getAttrString($labelAttributes) .'>' .$this->_getAttrString($labelAttributes).'>'
. '<input type="checkbox"' .'<input type="checkbox"'
. ' id="'.$selectId . $checkbox_id_suffix.'"' .' id="'.$selectId.$checkbox_id_suffix.'"'
. ' name="'.$selectName.'"' .' name="'.$selectName.'"'
. $checked .$checked
. $this->_getAttrString($option['attr']) .$this->_getAttrString($option['attr'])
. ' />' . $option['text'] . '</label>' .' />'.$option['text'].'</label>'
. PHP_EOL; .PHP_EOL;
} }
$strHtmlSelected .= $tab . '</div>'. PHP_EOL; $strHtmlSelected .= $tab.'</div>'.PHP_EOL;
$strHtmlHidden = ''; $strHtmlHidden = '';
$strHtmlUnselected = ''; $strHtmlUnselected = '';
@ -657,30 +704,38 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$strHtmlRemove = ''; $strHtmlRemove = '';
// build the select all button with all its attributes // build the select all button with all its attributes
$jsName = $this->_jsPrefix . $this->_jsPostfix; $jsName = $this->_jsPrefix.$this->_jsPostfix;
$attributes = array('onclick' => $jsName . $attributes = array(
"('". $selectId ."', 1);"); 'onclick' => $jsName.
"('".$selectId."', 1);"
);
$this->_allButtonAttributes $this->_allButtonAttributes
= array_merge($this->_allButtonAttributes, $attributes); = array_merge($this->_allButtonAttributes, $attributes);
$attrStrAll = $this->_getAttrString($this->_allButtonAttributes); $attrStrAll = $this->_getAttrString($this->_allButtonAttributes);
$strHtmlAll = "<input$attrStrAll />". PHP_EOL; $strHtmlAll = "<input$attrStrAll />".PHP_EOL;
// build the select none button with all its attributes // build the select none button with all its attributes
$attributes = array('onclick' => $jsName . $attributes = array(
"('". $selectId ."', 0);"); 'onclick' => $jsName.
"('".$selectId."', 0);"
);
$this->_noneButtonAttributes $this->_noneButtonAttributes
= array_merge($this->_noneButtonAttributes, $attributes); = array_merge($this->_noneButtonAttributes, $attributes);
$attrStrNone = $this->_getAttrString($this->_noneButtonAttributes); $attrStrNone = $this->_getAttrString($this->_noneButtonAttributes);
$strHtmlNone = "<input$attrStrNone />". PHP_EOL; $strHtmlNone = "<input$attrStrNone />".PHP_EOL;
// build the toggle selection button with all its attributes // build the toggle selection button with all its attributes
$attributes = array('onclick' => $jsName . $attributes = array(
"('". $selectId ."', 2);"); 'onclick' => $jsName.
"('".$selectId."', 2);"
);
$this->_toggleButtonAttributes $this->_toggleButtonAttributes
= array_merge($this->_toggleButtonAttributes, = array_merge(
$attributes); $this->_toggleButtonAttributes,
$attributes
);
$attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes); $attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes);
$strHtmlToggle = "<input$attrStrToggle />". PHP_EOL; $strHtmlToggle = "<input$attrStrToggle />".PHP_EOL;
$strHtmlMoveUp = ''; $strHtmlMoveUp = '';
$strHtmlMoveDown = ''; $strHtmlMoveDown = '';
@ -688,45 +743,51 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$strHtmlMoveBottom = ''; $strHtmlMoveBottom = '';
// default selection counters // default selection counters
$strHtmlSelectedCount = $selected_count . '/' . $unselected_count; $strHtmlSelectedCount = $selected_count.'/'.$unselected_count;
} else { } else {
// ... or a dual multi-select // ... or a dual multi-select
$this->_jsPostfix = 'moveSelection'; $this->_jsPostfix = 'moveSelection';
$jsName = $this->_jsPrefix . $this->_jsPostfix; $jsName = $this->_jsPrefix.$this->_jsPostfix;
// set name of Select From Box // set name of Select From Box
$this->_attributesUnselected $this->_attributesUnselected
= array('id' => $selectId . '-f', = array(
'id' => $selectId.'-f',
'name' => $selectNameFrom, 'name' => $selectNameFrom,
'ondblclick' => $jsName . 'ondblclick' => $jsName.
"('{$selectId}', ". "('{$selectId}', ".
"this.form.elements['" . $selectNameFrom . "'], " . "this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['".$selectNameTo."'], ".
"this.form.elements['" . $selectName . "'], " . "this.form.elements['".$selectName."'], ".
"'add', '{$this->_sort}')"); "'add', '{$this->_sort}')"
);
$this->_attributesUnselected $this->_attributesUnselected
= array_merge($this->_attributes, $this->_attributesUnselected); = array_merge($this->_attributes, $this->_attributesUnselected);
$attrUnselected = $this->_getAttrString($this->_attributesUnselected); $attrUnselected = $this->_getAttrString($this->_attributesUnselected);
// set name of Select To Box // set name of Select To Box
$this->_attributesSelected $this->_attributesSelected
= array('id' => $selectId . '-t', = array(
'id' => $selectId.'-t',
'name' => $selectNameTo, 'name' => $selectNameTo,
'ondblclick' => $jsName . 'ondblclick' => $jsName.
"('{$selectId}', " . "('{$selectId}', ".
"this.form.elements['" . $selectNameFrom . "'], " . "this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['" . $selectNameTo . "'], ". "this.form.elements['".$selectNameTo."'], ".
"this.form.elements['" . $selectName . "'], " . "this.form.elements['".$selectName."'], ".
"'remove', '{$this->_sort}')"); "'remove', '{$this->_sort}')"
);
$this->_attributesSelected $this->_attributesSelected
= array_merge($this->_attributes, $this->_attributesSelected); = array_merge($this->_attributes, $this->_attributesSelected);
$attrSelected = $this->_getAttrString($this->_attributesSelected); $attrSelected = $this->_getAttrString($this->_attributesSelected);
// set name of Select hidden Box // set name of Select hidden Box
$this->_attributesHidden $this->_attributesHidden
= array('name' => $selectName, = array(
'style' => 'overflow: hidden; visibility: hidden; ' . 'name' => $selectName,
'width: 1px; height: 0;'); 'style' => 'overflow: hidden; visibility: hidden; '.
'width: 1px; height: 0;'
);
$this->_attributesHidden $this->_attributesHidden
= array_merge($this->_attributes, $this->_attributesHidden); = array_merge($this->_attributes, $this->_attributesHidden);
$attrHidden = $this->_getAttrString($this->_attributesHidden); $attrHidden = $this->_getAttrString($this->_attributesHidden);
@ -746,11 +807,16 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
foreach ($this->_options as $option) { foreach ($this->_options as $option) {
if (is_array($this->_values) if (is_array($this->_values)
&& in_array((string)$option['attr']['value'], && in_array(
$this->_values)) { (string)$option['attr']['value'],
$this->_values
)
) {
// Get the post order // Get the post order
$key = array_search($option['attr']['value'], $key = array_search(
$this->_values); $option['attr']['value'],
$this->_values
);
/** The items is *selected* so we want to put it /** The items is *selected* so we want to put it
in the 'selected' multi-select */ in the 'selected' multi-select */
@ -784,13 +850,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
= array_merge($this->_attributes, $this->_attributesUnselected); = array_merge($this->_attributes, $this->_attributesUnselected);
$attrUnselected = $this->_getAttrString($this->_attributesUnselected); $attrUnselected = $this->_getAttrString($this->_attributesUnselected);
} }
$strHtmlUnselected = "<select$attrUnselected>". PHP_EOL; $strHtmlUnselected = "<select$attrUnselected>".PHP_EOL;
if ($unselected_count > 0) { if ($unselected_count > 0) {
foreach ($arrHtmlUnselected as $data) { foreach ($arrHtmlUnselected as $data) {
$strHtmlUnselected $strHtmlUnselected
.= $tabs . $tab .= $tabs.$tab
. '<option' . $this->_getAttrString($data['attr']) . '>' .'<option'.$this->_getAttrString($data['attr']).'>'
. $data['text'] . '</option>' . PHP_EOL; .$data['text'].'</option>'.PHP_EOL;
} }
} else { } else {
$strHtmlUnselected .= '<option value="">&nbsp;</option>'; $strHtmlUnselected .= '<option value="">&nbsp;</option>';
@ -806,13 +872,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
= array_merge($this->_attributes, $this->_attributesSelected); = array_merge($this->_attributes, $this->_attributesSelected);
$attrSelected = $this->_getAttrString($this->_attributesSelected); $attrSelected = $this->_getAttrString($this->_attributesSelected);
} }
$strHtmlSelected = "<select$attrSelected>". PHP_EOL; $strHtmlSelected = "<select$attrSelected>".PHP_EOL;
if ($selected_count > 0) { if ($selected_count > 0) {
foreach ($arrHtmlSelected as $data) { foreach ($arrHtmlSelected as $data) {
$strHtmlSelected $strHtmlSelected
.= $tabs . $tab .= $tabs.$tab
. '<option' . $this->_getAttrString($data['attr']) . '>' .'<option'.$this->_getAttrString($data['attr']).'>'
. $data['text'] . '</option>' . PHP_EOL; .$data['text'].'</option>'.PHP_EOL;
} }
} else { } else {
$strHtmlSelected .= '<option value="">&nbsp;</option>'; $strHtmlSelected .= '<option value="">&nbsp;</option>';
@ -820,133 +886,154 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$strHtmlSelected .= '</select>'; $strHtmlSelected .= '</select>';
// The 'hidden' multi-select // The 'hidden' multi-select
$strHtmlHidden = "<select$attrHidden>". PHP_EOL; $strHtmlHidden = "<select$attrHidden>".PHP_EOL;
if (count($arrHtmlHidden) > 0) { if (count($arrHtmlHidden) > 0) {
foreach ($arrHtmlHidden as $data) { foreach ($arrHtmlHidden as $data) {
$strHtmlHidden $strHtmlHidden
.= $tabs . $tab .= $tabs.$tab
. '<option' . $this->_getAttrString($data['attr']) . '>' .'<option'.$this->_getAttrString($data['attr']).'>'
. $data['text'] . '</option>' . PHP_EOL; .$data['text'].'</option>'.PHP_EOL;
} }
} }
$strHtmlHidden .= '</select>'; $strHtmlHidden .= '</select>';
// build the remove button with all its attributes // build the remove button with all its attributes
$attributes $attributes = array(
= array('onclick' => $jsName . 'class' => 'btn btn-block ',
"('{$selectId}', " . 'onclick' => $jsName.
"this.form.elements['" . $selectNameFrom . "'], " . "('{$selectId}', ".
"this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['" . $selectName . "'], " . "this.form.elements['".$selectNameTo."'], ".
"'remove', '{$this->_sort}'); return false;"); "this.form.elements['".$selectName."'], ".
"'remove', '{$this->_sort}'); return false;"
);
$this->_removeButtonAttributes $this->_removeButtonAttributes
= array_merge($this->_removeButtonAttributes, $attributes); = array_merge($this->_removeButtonAttributes, $attributes);
$attrStrRemove = $this->_getAttrString($this->_removeButtonAttributes); $attrStrRemove = $this->_getAttrString($this->_removeButtonAttributes);
$strHtmlRemove = "<input$attrStrRemove />". PHP_EOL; //$strHtmlRemove = "<input$attrStrRemove />". PHP_EOL;
$strHtmlRemove = "<button$attrStrRemove /><i class='icon-arrow-left icon-large'></i></button>".PHP_EOL;
// build the add button with all its attributes // build the add button with all its attributes
$attributes $attributes
= array('onclick' => $jsName . = array(
"('{$selectId}', " . 'class' => 'btn btn-block ',
"this.form.elements['" . $selectNameFrom . "'], " . 'onclick' => $jsName.
"this.form.elements['" . $selectNameTo . "'], " . "('{$selectId}', ".
"this.form.elements['" . $selectName . "'], " . "this.form.elements['".$selectNameFrom."'], ".
"'add', '{$this->_sort}'); return false;"); "this.form.elements['".$selectNameTo."'], ".
"this.form.elements['".$selectName."'], ".
"'add', '{$this->_sort}'); return false;"
);
$this->_addButtonAttributes $this->_addButtonAttributes
= array_merge($this->_addButtonAttributes, $attributes); = array_merge($this->_addButtonAttributes, $attributes);
$attrStrAdd = $this->_getAttrString($this->_addButtonAttributes); $attrStrAdd = $this->_getAttrString($this->_addButtonAttributes);
$strHtmlAdd = "<input$attrStrAdd />". PHP_EOL; $strHtmlAdd = "<button$attrStrAdd /><i class='icon-arrow-right icon-large'></i></button>".PHP_EOL;
// build the select all button with all its attributes // build the select all button with all its attributes
$attributes $attributes
= array('onclick' => $jsName . = array(
"('{$selectId}', " . 'onclick' => $jsName.
"this.form.elements['" . $selectNameFrom . "'], " . "('{$selectId}', ".
"this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['" . $selectName . "'], " . "this.form.elements['".$selectNameTo."'], ".
"'all', '{$this->_sort}'); return false;"); "this.form.elements['".$selectName."'], ".
"'all', '{$this->_sort}'); return false;"
);
$this->_allButtonAttributes $this->_allButtonAttributes
= array_merge($this->_allButtonAttributes, $attributes); = array_merge($this->_allButtonAttributes, $attributes);
$attrStrAll = $this->_getAttrString($this->_allButtonAttributes); $attrStrAll = $this->_getAttrString($this->_allButtonAttributes);
$strHtmlAll = "<input$attrStrAll />". PHP_EOL; $strHtmlAll = "<input$attrStrAll />".PHP_EOL;
// build the select none button with all its attributes // build the select none button with all its attributes
$attributes $attributes
= array('onclick' => $jsName . = array(
"('{$selectId}', " . 'onclick' => $jsName.
"this.form.elements['" . $selectNameFrom . "'], " . "('{$selectId}', ".
"this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['" . $selectName . "'], " . "this.form.elements['".$selectNameTo."'], ".
"'none', '{$this->_sort}'); return false;"); "this.form.elements['".$selectName."'], ".
"'none', '{$this->_sort}'); return false;"
);
$this->_noneButtonAttributes $this->_noneButtonAttributes
= array_merge($this->_noneButtonAttributes, $attributes); = array_merge($this->_noneButtonAttributes, $attributes);
$attrStrNone = $this->_getAttrString($this->_noneButtonAttributes); $attrStrNone = $this->_getAttrString($this->_noneButtonAttributes);
$strHtmlNone = "<input$attrStrNone />". PHP_EOL; $strHtmlNone = "<input$attrStrNone />".PHP_EOL;
// build the toggle button with all its attributes // build the toggle button with all its attributes
$attributes $attributes
= array('onclick' => $jsName . = array(
"('{$selectId}', " . 'onclick' => $jsName.
"this.form.elements['" . $selectNameFrom . "'], " . "('{$selectId}', ".
"this.form.elements['" . $selectNameTo . "'], " . "this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['" . $selectName . "'], " . "this.form.elements['".$selectNameTo."'], ".
"'toggle', '{$this->_sort}'); return false;"); "this.form.elements['".$selectName."'], ".
"'toggle', '{$this->_sort}'); return false;"
);
$this->_toggleButtonAttributes $this->_toggleButtonAttributes
= array_merge($this->_toggleButtonAttributes, $attributes); = array_merge($this->_toggleButtonAttributes, $attributes);
$attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes); $attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes);
$strHtmlToggle = "<input$attrStrToggle />". PHP_EOL; $strHtmlToggle = "<input$attrStrToggle />".PHP_EOL;
// build the move up button with all its attributes // build the move up button with all its attributes
$attributes $attributes
= array('onclick' => "{$this->_jsPrefix}moveUp" . = array(
"(this.form.elements['" . $selectNameTo . "'], " . 'onclick' => "{$this->_jsPrefix}moveUp".
"this.form.elements['" . $selectName . "']); " . "(this.form.elements['".$selectNameTo."'], ".
"return false;"); "this.form.elements['".$selectName."']); ".
"return false;"
);
$this->_upButtonAttributes $this->_upButtonAttributes
= array_merge($this->_upButtonAttributes, $attributes); = array_merge($this->_upButtonAttributes, $attributes);
$attrStrUp = $this->_getAttrString($this->_upButtonAttributes); $attrStrUp = $this->_getAttrString($this->_upButtonAttributes);
$strHtmlMoveUp = "<input$attrStrUp />". PHP_EOL; $strHtmlMoveUp = "<input$attrStrUp />".PHP_EOL;
// build the move down button with all its attributes // build the move down button with all its attributes
$attributes $attributes
= array('onclick' => "{$this->_jsPrefix}moveDown" . = array(
"(this.form.elements['" . $selectNameTo . "'], " . 'onclick' => "{$this->_jsPrefix}moveDown".
"this.form.elements['" . $selectName . "']); " . "(this.form.elements['".$selectNameTo."'], ".
"return false;"); "this.form.elements['".$selectName."']); ".
"return false;"
);
$this->_downButtonAttributes $this->_downButtonAttributes
= array_merge($this->_downButtonAttributes, $attributes); = array_merge($this->_downButtonAttributes, $attributes);
$attrStrDown = $this->_getAttrString($this->_downButtonAttributes); $attrStrDown = $this->_getAttrString($this->_downButtonAttributes);
$strHtmlMoveDown = "<input$attrStrDown />". PHP_EOL; $strHtmlMoveDown = "<input$attrStrDown />".PHP_EOL;
// build the move top button with all its attributes // build the move top button with all its attributes
$attributes $attributes
= array('onclick' => "{$this->_jsPrefix}moveTop" . = array(
"(this.form.elements['" . $selectNameTo . "'], " . 'onclick' => "{$this->_jsPrefix}moveTop".
"this.form.elements['" . $selectName . "']); " . "(this.form.elements['".$selectNameTo."'], ".
"return false;"); "this.form.elements['".$selectName."']); ".
"return false;"
);
$this->_topButtonAttributes $this->_topButtonAttributes
= array_merge($this->_topButtonAttributes, $attributes); = array_merge($this->_topButtonAttributes, $attributes);
$attrStrTop = $this->_getAttrString($this->_topButtonAttributes); $attrStrTop = $this->_getAttrString($this->_topButtonAttributes);
$strHtmlMoveTop = "<input$attrStrTop />". PHP_EOL; $strHtmlMoveTop = "<input$attrStrTop />".PHP_EOL;
// build the move bottom button with all its attributes // build the move bottom button with all its attributes
$attributes $attributes
= array('onclick' => "{$this->_jsPrefix}moveBottom" . = array(
"(this.form.elements['" . $selectNameTo . "'], " . 'onclick' => "{$this->_jsPrefix}moveBottom".
"this.form.elements['" . $selectName . "']); " . "(this.form.elements['".$selectNameTo."'], ".
"return false;"); "this.form.elements['".$selectName."']); ".
"return false;"
);
$this->_bottomButtonAttributes $this->_bottomButtonAttributes
= array_merge($this->_bottomButtonAttributes, $attributes); = array_merge($this->_bottomButtonAttributes, $attributes);
$attrStrBottom = $this->_getAttrString($this->_bottomButtonAttributes); $attrStrBottom = $this->_getAttrString($this->_bottomButtonAttributes);
$strHtmlMoveBottom = "<input$attrStrBottom />". PHP_EOL; $strHtmlMoveBottom = "<input$attrStrBottom />".PHP_EOL;
// default selection counters // default selection counters
$strHtmlSelectedCount = $selected_count; $strHtmlSelectedCount = $selected_count;
} }
$strHtmlUnselectedCount = $unselected_count; $strHtmlUnselectedCount = $unselected_count;
$strHtmlSelectedCountId = $selectId .'_selected'; $strHtmlSelectedCountId = $selectId.'_selected';
$strHtmlUnselectedCountId = $selectId .'_unselected'; $strHtmlUnselectedCountId = $selectId.'_unselected';
// render all part of the multi select component with the template // render all part of the multi select component with the template
$strHtml = $this->_elementTemplate; $strHtml = $this->_elementTemplate;
@ -959,7 +1046,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
// render extra labels, if any // render extra labels, if any
if (is_array($labels)) { if (is_array($labels)) {
foreach ($labels as $key => $text) { foreach ($labels as $key => $text) {
$key = is_int($key)? $key + 2: $key; $key = is_int($key) ? $key + 2 : $key;
$strHtml = str_replace("{label_{$key}}", $text, $strHtml); $strHtml = str_replace("{label_{$key}}", $text, $strHtml);
$strHtml = str_replace("<!-- BEGIN label_{$key} -->", '', $strHtml); $strHtml = str_replace("<!-- BEGIN label_{$key} -->", '', $strHtml);
$strHtml = str_replace("<!-- END label_{$key} -->", '', $strHtml); $strHtml = str_replace("<!-- END label_{$key} -->", '', $strHtml);
@ -967,31 +1054,53 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
} }
// clean up useless label tags // clean up useless label tags
if (strpos($strHtml, '{label_')) { if (strpos($strHtml, '{label_')) {
$strHtml = preg_replace('/\s*<!-- BEGIN label_(\S+) -->'. $strHtml = preg_replace(
'.*<!-- END label_\1 -->\s*/i', '', $strHtml); '/\s*<!-- BEGIN label_(\S+) -->'.
'.*<!-- END label_\1 -->\s*/i',
'',
$strHtml
);
} }
$placeHolders = array( $placeHolders = array(
'{stylesheet}', '{javascript}', '{stylesheet}',
'{javascript}',
'{class}', '{class}',
'{unselected_count_id}', '{selected_count_id}', '{unselected_count_id}',
'{unselected_count}', '{selected_count}', '{selected_count_id}',
'{unselected}', '{selected}', '{unselected_count}',
'{add}', '{remove}', '{selected_count}',
'{all}', '{none}', '{toggle}', '{unselected}',
'{moveup}', '{movedown}', '{selected}',
'{movetop}', '{movebottom}' '{add}',
'{remove}',
'{all}',
'{none}',
'{toggle}',
'{moveup}',
'{movedown}',
'{movetop}',
'{movebottom}'
); );
$htmlElements = array( $htmlElements = array(
$this->getElementCss(false), $this->getElementJs(false), $this->getElementCss(false),
$this->getElementJs(false),
$this->_tableAttributes, $this->_tableAttributes,
$strHtmlUnselectedCountId, $strHtmlSelectedCountId, $strHtmlUnselectedCountId,
$strHtmlUnselectedCount, $strHtmlSelectedCount, $strHtmlSelectedCountId,
$strHtmlUnselected, $strHtmlSelected . $strHtmlHidden, $strHtmlUnselectedCount,
$strHtmlAdd, $strHtmlRemove, $strHtmlSelectedCount,
$strHtmlAll, $strHtmlNone, $strHtmlToggle, $strHtmlUnselected,
$strHtmlMoveUp, $strHtmlMoveDown, $strHtmlSelected.$strHtmlHidden,
$strHtmlMoveTop, $strHtmlMoveBottom $strHtmlAdd,
$strHtmlRemove,
$strHtmlAll,
$strHtmlNone,
$strHtmlToggle,
$strHtmlMoveUp,
$strHtmlMoveDown,
$strHtmlMoveTop,
$strHtmlMoveBottom
); );
$strHtml = str_replace($placeHolders, $htmlElements, $strHtml); $strHtml = str_replace($placeHolders, $htmlElements, $strHtml);
@ -999,7 +1108,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$comment = $this->getComment(); $comment = $this->getComment();
if (!empty($comment)) { if (!empty($comment)) {
$strHtml = $tabs . '<!-- ' . $comment . " //-->" . PHP_EOL . $strHtml; $strHtml = $tabs.'<!-- '.$comment." //-->".PHP_EOL.$strHtml;
} }
return $strHtml; return $strHtml;
@ -1017,8 +1126,8 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
*/ */
function getElementJs($raw = true, $min = true) function getElementJs($raw = true, $min = true)
{ {
$js = '@data_dir@' . DIRECTORY_SEPARATOR $js = '@data_dir@'.DIRECTORY_SEPARATOR
. '@package_name@' . DIRECTORY_SEPARATOR; .'@package_name@'.DIRECTORY_SEPARATOR;
$js = api_get_path(LIBRARY_PATH).'javascript'.DIRECTORY_SEPARATOR.'pear'.DIRECTORY_SEPARATOR; $js = api_get_path(LIBRARY_PATH).'javascript'.DIRECTORY_SEPARATOR.'pear'.DIRECTORY_SEPARATOR;
@ -1036,11 +1145,11 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
if ($raw !== true) { if ($raw !== true) {
$js = '<script type="text/javascript">' $js = '<script type="text/javascript">'
. PHP_EOL . '//<![CDATA[' .PHP_EOL.'//<![CDATA['
. PHP_EOL . $js .PHP_EOL.$js
. PHP_EOL . '//]]>' .PHP_EOL.'//]]>'
. PHP_EOL . '</script>' .PHP_EOL.'</script>'
. PHP_EOL; .PHP_EOL;
} }
return $js; return $js;
} }
@ -1063,9 +1172,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
* @throws PEAR_Error * @throws PEAR_Error
* @see loadArray() * @see loadArray()
*/ */
function load(&$options, function load(
$param1 = null, $param2 = null, $param3 = null, $param4 = null) &$options,
{ $param1 = null,
$param2 = null,
$param3 = null,
$param4 = null
) {
if (is_array($options)) { if (is_array($options)) {
$ret = $this->loadArray($options, $param1); $ret = $this->loadArray($options, $param1);
} else { } else {
@ -1092,10 +1205,12 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
function loadArray($arr, $values = null) function loadArray($arr, $values = null)
{ {
if (!is_array($arr)) { if (!is_array($arr)) {
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' . return PEAR::throwError(
'Argument 1 of HTML_QuickForm_advmultiselect::'.
'loadArray is not a valid array', 'loadArray is not a valid array',
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
array('level' => 'exception')); array('level' => 'exception')
);
} }
if (isset($values)) { if (isset($values)) {
$this->setSelected($values); $this->setSelected($values);
@ -1129,19 +1244,23 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
function setPersistantOptions($optionValues, $persistant = true) function setPersistantOptions($optionValues, $persistant = true)
{ {
if (!is_bool($persistant)) { if (!is_bool($persistant)) {
return PEAR::throwError('Argument 2 of HTML_QuickForm_advmultiselect::' . return PEAR::throwError(
'Argument 2 of HTML_QuickForm_advmultiselect::'.
'setPersistantOptions is not a boolean', 'setPersistantOptions is not a boolean',
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
array('level' => 'exception')); array('level' => 'exception')
);
} }
if (is_string($optionValues)) { if (is_string($optionValues)) {
$optionValues = array($optionValues); $optionValues = array($optionValues);
} }
if (!is_array($optionValues)) { if (!is_array($optionValues)) {
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' . return PEAR::throwError(
'Argument 1 of HTML_QuickForm_advmultiselect::'.
'setPersistantOptions is not a valid array', 'setPersistantOptions is not a valid array',
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
array('level' => 'exception')); array('level' => 'exception')
);
} }
foreach ($this->_options as $k => $v) { foreach ($this->_options as $k => $v) {
@ -1182,5 +1301,9 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
// @todo this fires an PHP notice, needed in order to parse the advmultiselect test it in main/group/group_edit.php // @todo this fires an PHP notice, needed in order to parse the advmultiselect test it in main/group/group_edit.php
if (class_exists('HTML_QuickForm')) { if (class_exists('HTML_QuickForm')) {
@HTML_QuickForm::registerElementType('advmultiselect','HTML/QuickForm/advmultiselect.php', 'HTML_QuickForm_advmultiselect'); @HTML_QuickForm::registerElementType(
'advmultiselect',
'HTML/QuickForm/advmultiselect.php',
'HTML_QuickForm_advmultiselect'
);
} }

@ -29,7 +29,8 @@ class HTML_QuickForm_label extends HTML_QuickForm_static
* @access public * @access public
* @return void * @return void
*/ */
function HTML_QuickForm_label($label = null, $text = null) { function HTML_QuickForm_label($label = null, $text = null)
{
$this->HTML_QuickForm_static(null, $label, $text); $this->HTML_QuickForm_static(null, $label, $text);
$this->_type = 'html'; $this->_type = 'html';
} }
@ -44,22 +45,19 @@ class HTML_QuickForm_label extends HTML_QuickForm_static
* @access public * @access public
* @return void * @return void
*/ */
function accept(&$renderer, $required=false, $error=null) { function accept(&$renderer, $required = false, $error = null)
{
$renderer->renderHtml($this); $renderer->renderHtml($this);
} }
function toHtml() { function toHtml()
return '<div class="control-group "> {
return '<div class="control-group">
<label class="control-label">'.$this->getLabel().'</label> <label class="control-label">'.$this->getLabel().'</label>
<div class="controls"> <div class="controls">
'.HTML_QuickForm_static::toHtml().' '.HTML_QuickForm_static::toHtml().'
</div> </div>
</div> </div>
'; ';
} //end func toHtml }
}
// }}}
} //end class HTML_QuickForm_html

@ -65,7 +65,7 @@ if (api_is_course_admin()) {
$tool_name = get_lang('SurveyPublication'); $tool_name = get_lang('SurveyPublication');
// Displaying the header // Displaying the header
Display::display_header($tool_name,'Survey'); Display::display_header($tool_name, 'Survey');
echo '<script> echo '<script>
$(function() { $(function() {
@ -77,7 +77,9 @@ $(function() {
// Checking if there is another survey with this code. // Checking if there is another survey with this code.
// If this is the case there will be a language choice // If this is the case there will be a language choice
$sql = "SELECT * FROM $table_survey WHERE c_id = $course_id AND code='".Database::escape_string($survey_data['code'])."'"; $sql = "SELECT * FROM $table_survey WHERE c_id = $course_id AND code='".Database::escape_string(
$survey_data['code']
)."'";
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result) > 1) { if (Database::num_rows($result) > 1) {
Display::display_warning_message(get_lang('IdenticalSurveycodeWarning')); Display::display_warning_message(get_lang('IdenticalSurveycodeWarning'));
@ -98,37 +100,32 @@ $form = new FormValidator('publish_form', 'post', api_get_self().'?survey_id='.$
$form->addElement('header', '', $tool_name); $form->addElement('header', '', $tool_name);
// Course users // Course users
$complete_user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), '', api_sort_by_first_name() ? 'ORDER BY firstname' : 'ORDER BY lastname'); $complete_user_list = CourseManager::get_user_list_from_course_code(
api_get_course_id(),
api_get_session_id(),
'',
api_sort_by_first_name() ? 'ORDER BY firstname' : 'ORDER BY lastname'
);
$possible_users = array(); $possible_users = array();
foreach ($complete_user_list as & $user) { foreach ($complete_user_list as & $user) {
$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); $possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
} }
$list = UserManager::generate_user_group_array(api_get_course_id(), api_get_session_id()); $list = UserManager::generate_user_group_array(api_get_course_id(), api_get_session_id());
$users = $form->addElement('advmultiselect', 'course_users', get_lang('CourseUsers'), $list);
$users = $form->addElement('advmultiselect', 'course_users', get_lang('CourseUsers'), $list, 'style="width: 250px; height: 200px;"'); $users->setButtonAttributes('add');
$users->setButtonAttributes('remove');
//$users = $form->addElement('advmultiselect', 'course_users', get_lang('CourseUsers'), $possible_users, 'style="width: 250px; height: 200px;"');
$users->setElementTemplate('
{javascript}
<table{class}>
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
<td valign="top">{unselected}</td>
<td align="center">{add}<br /><br />{remove}</td>
<td valign="top">{selected}</td>
</tr>
</table>
');
$users->setButtonAttributes('add', array('class' => 'btn arrowr'));
$users->setButtonAttributes('remove', array('class' => 'btn arrowl'));
// Additional users // Additional users
$form->addElement('textarea', 'additional_users', array(get_lang('AdditonalUsers'), get_lang('AdditonalUsersComment')), array('class' => 'span6', 'rows' => 5)); $form->addElement(
'textarea',
'additional_users',
array(get_lang('AdditonalUsers'), get_lang('AdditonalUsersComment')),
array('class' => 'span6', 'rows' => 5)
);
$form->addElement('html', '<div id="check_mail">'); $form->addElement('html', '<div id="check_mail">');
$form->addElement('checkbox', 'send_mail','', get_lang('SendMail')); $form->addElement('checkbox', 'send_mail', '', get_lang('SendMail'));
$form->addElement('html', '</div>'); $form->addElement('html', '</div>');
$form->addElement('html', '<div id="mail_text">'); $form->addElement('html', '<div id="mail_text">');
@ -136,7 +133,13 @@ $form->addElement('html', '<div id="mail_text">');
// The title of the mail // The title of the mail
$form->addElement('text', 'mail_title', get_lang('MailTitle'), array('class' => 'span6')); $form->addElement('text', 'mail_title', get_lang('MailTitle'), array('class' => 'span6'));
// The text of the mail // The text of the mail
$form->addElement('html_editor', 'mail_text', array(get_lang('MailText'), get_lang('UseLinkSyntax')), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '150')); $form->addElement(
'html_editor',
'mail_text',
array(get_lang('MailText'), get_lang('UseLinkSyntax')),
null,
array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '150')
);
$form->addElement('html', '</div>'); $form->addElement('html', '</div>');
// You cab send a reminder to unanswered people if the survey is not anonymous // You cab send a reminder to unanswered people if the survey is not anonymous
if ($survey_data['anonymous'] != 1) { if ($survey_data['anonymous'] != 1) {
@ -189,8 +192,14 @@ if ($form->validate()) {
// Save the invitation mail // Save the invitation mail
SurveyUtil::save_invite_mail($values['mail_text'], $values['mail_title'], !empty($survey_data['invite_mail'])); SurveyUtil::save_invite_mail($values['mail_text'], $values['mail_title'], !empty($survey_data['invite_mail']));
// Saving the invitations for the course users // Saving the invitations for the course users
$count_course_users = SurveyUtil::save_invitations($values['course_users'], $values['mail_title'], $count_course_users = SurveyUtil::save_invitations(
$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']); $values['course_users'],
$values['mail_title'],
$values['mail_text'],
$values['resend_to_all'],
$values['send_mail'],
$values['remindUnAnswered']
);
// Saving the invitations for the additional users // Saving the invitations for the additional users
$values['additional_users'] = $values['additional_users'].';'; // This is for the case when you enter only one email $values['additional_users'] = $values['additional_users'].';'; // This is for the case when you enter only one email
@ -199,8 +208,14 @@ if ($form->validate()) {
for ($i = 0; $i < count($additional_users); $i++) { for ($i = 0; $i < count($additional_users); $i++) {
$additional_users[$i] = trim($additional_users[$i]); $additional_users[$i] = trim($additional_users[$i]);
} }
$counter_additional_users = SurveyUtil::save_invitations($additional_users, $values['mail_title'], $counter_additional_users = SurveyUtil::save_invitations(
$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']); $additional_users,
$values['mail_title'],
$values['mail_text'],
$values['resend_to_all'],
$values['send_mail'],
$values['remindUnAnswered']
);
// Updating the invited field in the survey table // Updating the invited field in the survey table
SurveyUtil::update_count_invited($survey_data['code']); SurveyUtil::update_count_invited($survey_data['code']);
$total_count = $count_course_users + $counter_additional_users; $total_count = $count_course_users + $counter_additional_users;
@ -228,7 +243,9 @@ if ($form->validate()) {
$defaults['mail_title'] = $survey_data['mail_subject']; $defaults['mail_title'] = $survey_data['mail_subject'];
$defaults['send_mail'] = 1; $defaults['send_mail'] = 1;
$defaults['course_users'] = array_keys(UserManager::transform_user_group_array($defaults['course_users'], $defaults['course_groups'], true, true)); $defaults['course_users'] = array_keys(
UserManager::transform_user_group_array($defaults['course_users'], $defaults['course_groups'], true, true)
);
$form->setDefaults($defaults); $form->setDefaults($defaults);
$form->display(); $form->display();

Loading…
Cancel
Save