Exemplo n.º 1
0
 /**
  * Loads the data for the link type from the database
  *
  * @param string label
  * @return LinkType object (this)  (or Error object)
  */
 function loadByLabel($label)
 {
     global $DB, $CFG, $USER, $ERROR, $HUB_SQL;
     $currentuser = '';
     if (isset($USER->userid)) {
         $currentuser = $USER->userid;
     }
     $params = array();
     $params[0] = $label;
     $params[1] = $currentuser;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_LINKTYPE_BY_LABEL_SELECT, $params);
     if ($resArray !== false) {
         $count = count($resArray);
         if ($count == 0) {
             $ERROR = new error();
             $ERROR->createLinkTypeNotFoundError($this->linktypeid);
             return $ERROR;
         } else {
             for ($i = 0; $i < $count; $i++) {
                 $array = $resArray[$i];
                 $this->linktypeid = $array['LinkTypeID'];
             }
         }
     } else {
         return database_error();
     }
     return $this->load();
 }