Exemplo n.º 1
0
 public function load_choices()
 {
     if (is_array($this->choices)) {
         return true;
     }
     $result = false;
     $services = block_mhaairs_connect::get_services(true);
     if (is_array($services) && isset($services['Tools'])) {
         foreach ($services['Tools'] as $item) {
             $choices[$item['ServiceID']] = '  ' . $item['ServiceName'];
         }
         asort($choices);
         $this->choices = $choices;
         $result = true;
     }
     return $result;
 }
 /**
  * Returns list of services to display in the block content,
  * or false if no services are available.
  * For each services, returns:
  *  ServiceID       string id
  *  ServiceIconUrl  string url of an image
  *  ServiceName     string name
  *  ServiceUrl      string url
  *
  * @return array|false Array of arrays.
  */
 protected function get_service_data()
 {
     $result = false;
     // Some services must be configured site level.
     if (!$this->displayservices) {
         return $result;
     }
     // Initialize the display list with the services enabled in the site level.
     $displaylist = explode(',', $this->displayservices);
     // Limit to instructor selection in the instance, if any.
     // If the instance has not been configured, all services
     // enabled in the site level will be displayed.
     if (!empty($this->config)) {
         foreach ($displaylist as $key => $serviceid) {
             if (empty($this->config->{$serviceid})) {
                 unset($displaylist[$key]);
             }
         }
     }
     // Empty display list means that block needs reconfiguration.
     if (empty($displaylist)) {
         return $result;
     }
     natcasesort($displaylist);
     // Get the data of all available services.
     $services = !empty($this->servicedata) ? $this->servicedata : block_mhaairs_connect::get_services();
     if ($services === false) {
         return $result;
     }
     // Collate service data for displayed services.
     $result = array();
     foreach ($displaylist as $serviceid) {
         foreach ($services['Tools'] as $vset) {
             if ($vset['ServiceID'] == $serviceid) {
                 $result[] = $vset;
             }
         }
     }
     return $result;
 }