Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 127... Línea 127...
127
                        )
127
                        )
128
                    );
128
                    );
Línea 129... Línea 129...
129
 
129
 
130
                    if ($USER->id != $user->id) {
130
                    if ($USER->id != $user->id) {
-
 
131
                        $iscontact = \core_message\api::is_contact($USER->id, $user->id);
-
 
132
                        $isrequested = \core_message\api::get_contact_requests_between_users($USER->id, $user->id);
-
 
133
                        $contacturlaction = '';
-
 
134
                        $linkattributes = \core_message\helper::togglecontact_link_params(
-
 
135
                            $user,
-
 
136
                            $iscontact,
-
 
137
                            true,
-
 
138
                            !empty($isrequested),
-
 
139
                        );
-
 
140
                        // If the user is not a contact.
-
 
141
                        if (!$iscontact) {
-
 
142
                            if ($isrequested) {
-
 
143
                                // We just need the first request.
-
 
144
                                $requests = array_shift($isrequested);
-
 
145
                                if ($requests->userid == $USER->id) {
-
 
146
                                    // If the user has requested to be a contact.
-
 
147
                                    $contacttitle = 'contactrequestsent';
-
 
148
                                } else {
-
 
149
                                    // If the user has been requested to be a contact.
-
 
150
                                    $contacttitle = 'waitingforcontactaccept';
-
 
151
                                }
-
 
152
                                $linkattributes = array_merge($linkattributes, [
-
 
153
                                    'class' => 'disabled',
-
 
154
                                    'tabindex' => '-1',
-
 
155
                                ]);
-
 
156
                            } else {
-
 
157
                                // If the user is not a contact and has not requested to be a contact.
-
 
158
                                $contacttitle = 'addtoyourcontacts';
-
 
159
                                $contacturlaction = 'addcontact';
-
 
160
                            }
-
 
161
                            $contactimage = 'addcontact';
-
 
162
                        } else {
131
                        $iscontact = \core_message\api::is_contact($USER->id, $user->id);
163
                            // If the user is a contact.
132
                        $contacttitle = $iscontact ? 'removefromyourcontacts' : 'addtoyourcontacts';
164
                            $contacttitle = 'removefromyourcontacts';
133
                        $contacturlaction = $iscontact ? 'removecontact' : 'addcontact';
165
                            $contacturlaction = 'removecontact';
-
 
166
                            $contactimage = 'removecontact';
134
                        $contactimage = $iscontact ? 'removecontact' : 'addcontact';
167
                        }
135
                        $userbuttons['togglecontact'] = array(
168
                        $userbuttons['togglecontact'] = array(
136
                                'buttontype' => 'togglecontact',
169
                                'buttontype' => 'togglecontact',
137
                                'title' => get_string($contacttitle, 'message'),
170
                                'title' => get_string($contacttitle, 'message'),
138
                                'url' => new moodle_url('/message/index.php', array(
171
                                'url' => new moodle_url('/message/index.php', array(
139
                                        'user1' => $USER->id,
172
                                        'user1' => $USER->id,
140
                                        'user2' => $user->id,
173
                                        'user2' => $user->id,
141
                                        $contacturlaction => $user->id,
174
                                        $contacturlaction => $user->id,
142
                                        'sesskey' => sesskey())
175
                                        'sesskey' => sesskey())
143
                                ),
176
                                ),
144
                                'image' => $contactimage,
177
                                'image' => $contactimage,
145
                                'linkattributes' => \core_message\helper::togglecontact_link_params($user, $iscontact),
178
                                'linkattributes' => $linkattributes,
146
                                'page' => $this->page
179
                                'page' => $this->page
147
                            );
180
                            );
Línea 148... Línea 181...
148
                    }
181
                    }