Exemplo n.º 1
0
 /**
  * Formats various attributes for human consumption.
  * @param array $row An array for a single result.
  * @return array The transformed result.
  */
 protected function results_row_transform(array $row)
 {
     static $canenrolintocluster = null;
     if ($canenrolintocluster === null) {
         $canenrolintocluster = usersetpage::can_enrol_into_cluster($this->usersetid);
     }
     $row = parent::results_row_transform($row);
     $row['canunassign'] = $canenrolintocluster === true ? '1' : '0';
     if (clusteruserpage::can_manage_assoc($row['element_id'], $this->usersetid) !== true) {
         $row['canunassign'] = '0';
     }
     if (isset($row['clstass_plugin'])) {
         if ($row['clstass_plugin'] !== 'manual') {
             $row['canunassign'] = '0';
         }
         $row['clstass_plugin'] = $row['clstass_plugin'] === 'manual' ? 'no' : 'yes';
         $row['clstass_plugin'] = get_string($row['clstass_plugin'], 'moodle');
     }
     return $row;
 }
Exemplo n.º 2
0
 /**
  * Determine whether the current user can assign the given user to the given userset.
  *
  * @param int $userid The ID of the user.
  * @param int $usersetid The ID of the userset.
  * @return bool Whether the user can assign (true) or not (false)
  */
 protected function can_unassign($userid, $usersetid)
 {
     return clusteruserpage::can_manage_assoc($userid, $usersetid);
 }