Commit a2fd943a authored by Richard Mansfield's avatar Richard Mansfield Committed by Gerrit Code Review
Browse files

Merge "Use new add friend form functions on the user/view page (bug #861985)"

parents 76844f05 cdfbf8fb
......@@ -1700,7 +1700,8 @@ function acceptfriend_form($friendid) {
'name' => 'acceptfriend' . (int) $friendid,
'validatecallback' => 'acceptfriend_validate',
'successcallback' => 'acceptfriend_submit',
'renderer' => 'div',
'renderer' => 'oneline',
'class' => 'oneline inline',
'autofocus' => 'false',
'elements' => array(
'acceptfriend_submit' => array(
......
......@@ -19,7 +19,10 @@
{if $relationship == 'pending'}
<div class="message">
{str tag='whymakemeyourfriend' section='group'} {$message}
{$requestform|safe}
<div>
{$acceptform|safe}
<a class="btn" id="approve_deny_friendrequest_deny" href="{$WWWROOT}user/denyrequest.php?id={$USERID}&returnto=view">{str tag=denyrequest section=group}</a>
</div>
</div>
{/if}
<div id="userview">
......
......@@ -37,6 +37,13 @@ require_once('group.php');
require_once('pieforms/pieform.php');
require_once(get_config('libroot') . 'view.php');
if (param_variable('acceptfriend_submit', null)) {
acceptfriend_form(param_integer('id'));
}
else if (param_variable('addfriend_submit', null)) {
addfriend_form(param_integer('id'));
}
$loggedinid = $USER->get('id');
if (!empty($loggedinid)) {
$userid = param_integer('id', $loggedinid);
......@@ -221,48 +228,14 @@ if (!empty($loggedinid) && $loggedinid != $userid) {
}
else if ($record = get_record('usr_friend_request', 'requester', $userid, 'owner', $loggedinid)) {
$relationship = 'pending';
$requestform = pieform(array(
'name' =>'approve_deny_friendrequest',
'renderer' => 'oneline',
'autofocus' => false,
'elements' => array(
'approve' => array(
'type' => 'submit',
'value' => get_string('approverequest', 'group'),
),
'deny' => array(
'type' => 'submit',
'value' => get_string('denyrequest', 'group')
),
'id' => array(
'type' => 'hidden',
'value' => $userid
)
)
));
$smarty->assign('message', $record->message);
$smarty->assign('requestform', $requestform);
$smarty->assign('acceptform', acceptfriend_form($userid));
}
else {
$relationship = 'none';
$friendscontrol = get_account_preference($userid, 'friendscontrol');
if ($friendscontrol == 'auto') {
$newfriendform = pieform(array(
'name' => 'addfriend',
'autofocus' => false,
'renderer' => 'div',
'elements' => array(
'add' => array(
'type' => 'submit',
'value' => get_string('addtomyfriends', 'group')
),
'id' => array(
'type' => 'hidden',
'value' => $userid
)
)
));
$smarty->assign('newfriendform', $newfriendform);
$smarty->assign('newfriendform', addfriend_form($userid));
}
$smarty->assign('friendscontrol', $friendscontrol);
}
......@@ -349,12 +322,3 @@ function addmember_submit(Pieform $form, $values) {
}
redirect('/user/view.php?id=' . $userid);
}
function approve_deny_friendrequest_submit(Pieform $form, $values) {
if (isset($values['deny'])) {
redirect('/user/denyrequest.php?id=' . $values['id'] . '&returnto=view');
}
else {
acceptfriend_submit($form, $values);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment