Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 4577... Línea 4577...
4577
                        )
4577
                        )
4578
                    );
4578
                    );
Línea 4579... Línea 4579...
4579
 
4579
 
4580
                    if ($USER->id != $user->id) {
4580
                    if ($USER->id != $user->id) {
-
 
4581
                        $iscontact = \core_message\api::is_contact($USER->id, $user->id);
-
 
4582
                        $isrequested = \core_message\api::get_contact_requests_between_users($USER->id, $user->id);
-
 
4583
                        $contacturlaction = '';
-
 
4584
                        $linkattributes = \core_message\helper::togglecontact_link_params(
-
 
4585
                            $user,
-
 
4586
                            $iscontact,
-
 
4587
                            true,
-
 
4588
                            !empty($isrequested),
-
 
4589
                        );
-
 
4590
                        // If the user is not a contact.
-
 
4591
                        if (!$iscontact) {
-
 
4592
                            if ($isrequested) {
-
 
4593
                                // We just need the first request.
-
 
4594
                                $requests = array_shift($isrequested);
-
 
4595
                                if ($requests->userid == $USER->id) {
-
 
4596
                                    // If the user has requested to be a contact.
-
 
4597
                                    $contacttitle = 'contactrequestsent';
-
 
4598
                                } else {
-
 
4599
                                    // If the user has been requested to be a contact.
-
 
4600
                                    $contacttitle = 'waitingforcontactaccept';
-
 
4601
                                }
-
 
4602
                                $linkattributes = array_merge($linkattributes, [
-
 
4603
                                    'class' => 'disabled',
-
 
4604
                                    'tabindex' => '-1',
-
 
4605
                                ]);
-
 
4606
                            } else {
-
 
4607
                                // If the user is not a contact and has not requested to be a contact.
-
 
4608
                                $contacttitle = 'addtoyourcontacts';
-
 
4609
                                $contacturlaction = 'addcontact';
-
 
4610
                            }
-
 
4611
                            $contactimage = 'addcontact';
-
 
4612
                        } else {
4581
                        $iscontact = \core_message\api::is_contact($USER->id, $user->id);
4613
                            // If the user is a contact.
4582
                        $contacttitle = $iscontact ? 'removefromyourcontacts' : 'addtoyourcontacts';
4614
                            $contacttitle = 'removefromyourcontacts';
4583
                        $contacturlaction = $iscontact ? 'removecontact' : 'addcontact';
4615
                            $contacturlaction = 'removecontact';
-
 
4616
                            $contactimage = 'removecontact';
4584
                        $contactimage = $iscontact ? 'removecontact' : 'addcontact';
4617
                        }
4585
                        $userbuttons['togglecontact'] = array(
4618
                        $userbuttons['togglecontact'] = array(
4586
                                'buttontype' => 'togglecontact',
4619
                                'buttontype' => 'togglecontact',
4587
                                'title' => get_string($contacttitle, 'message'),
4620
                                'title' => get_string($contacttitle, 'message'),
4588
                                'url' => new moodle_url('/message/index.php', array(
4621
                                'url' => new moodle_url('/message/index.php', array(
4589
                                        'user1' => $USER->id,
4622
                                        'user1' => $USER->id,
4590
                                        'user2' => $user->id,
4623
                                        'user2' => $user->id,
4591
                                        $contacturlaction => $user->id,
4624
                                        $contacturlaction => $user->id,
4592
                                        'sesskey' => sesskey())
4625
                                        'sesskey' => sesskey())
4593
                                ),
4626
                                ),
4594
                                'image' => $contactimage,
4627
                                'image' => $contactimage,
4595
                                'linkattributes' => \core_message\helper::togglecontact_link_params($user, $iscontact),
4628
                                'linkattributes' => $linkattributes,
4596
                                'page' => $this->page
4629
                                'page' => $this->page
4597
                            );
4630
                            );
4598
                    }
4631
                    }
4599
                }
4632
                }
Línea 4610... Línea 4643...
4610
        $contextheader = new context_header($heading, $headinglevel, $imagedata, $userbuttons);
4643
        $contextheader = new context_header($heading, $headinglevel, $imagedata, $userbuttons);
4611
        return $this->render($contextheader);
4644
        return $this->render($contextheader);
4612
    }
4645
    }
Línea 4613... Línea 4646...
4613
 
4646
 
-
 
4647
    /**
-
 
4648
     * Renders the header bar.
-
 
4649
     *
-
 
4650
     * @param context_header $contextheader Header bar object.
-
 
4651
     * @return string HTML for the header bar.
-
 
4652
     */
-
 
4653
    protected function render_context_header(context_header $contextheader) {
-
 
4654
        $context = $contextheader->export_for_template($this);
-
 
4655
        return $this->render_from_template('core/context_header', $context);
-
 
4656
    }
-
 
4657
 
4614
    /**
4658
    /**
4615
     * Renders the skip links for the page.
4659
     * Renders the skip links for the page.
4616
     *
4660
     *
4617
     * @param array $links List of skip links.
4661
     * @param array $links List of skip links.
4618
     * @return string HTML for the skip links.
4662
     * @return string HTML for the skip links.