Пример #1
0
 /**
  * loads and prepares all extra fields to be put in the
  * object via the setExtra method called in the multiport
  * 
  * NOTE: this MUST be implemented if user class hasExtra is true.
  * can be empty or removed (no, it won't be called) if hasExtra is false.
  *
  * @param int $userId
  * @return array extra user data stored in the object
  * 
  * @access public
  */
 public function getExtraData(ADAUser $userObj)
 {
     $db =& $this->getConnection();
     if (AMA_DB::isError($db)) {
         return $db;
     }
     /**
      * get extras from table ADAUser::getExtraTableKeyProperty()
      */
     $selQry = "SELECT " . implode(", ", $userObj->getExtraFields()) . " FROM " . ADAUser::getExtraTableName() . " WHERE " . ADAUser::getExtraTableKeyProperty() . "=?";
     $returnArr = $this->getRowPrepared($selQry, array($userObj->getId()), AMA_FETCH_ASSOC);
     /**
      * load data form tables that have a 1:n relationship with studente table.
      *
      *  $tablseToLoad is the array of tables to be loaded. WITHOUT PREFIX.
      *  $tablesPrefix is the prefix of the table in the DB.
      *
      *  the foreach loop does the magic
      */
     $tablesToLoad = ADAUser::getLinkedTables();
     $tablesPrefix = ADAUser::getTablesPrefix();
     if (!is_null($tablesToLoad)) {
         foreach ($tablesToLoad as $table) {
             if (!empty($table) && class_exists($table)) {
                 $selQry = "SELECT " . implode(", ", $table::getFields()) . " FROM " . $tablesPrefix . $table . " WHERE " . $table::getForeignKeyProperty() . "=?" . " ORDER BY " . $table::getKeyProperty() . " ASC";
                 $extraArr = $this->getAllPrepared($selQry, array($userObj->getId()), AMA_FETCH_ASSOC);
                 foreach ($extraArr as $extraKey => $extraElement) {
                     foreach ($extraElement as $key => $val) {
                         if (stripos($key, "date") !== false) {
                             $extraArr[$extraKey][$key] = ts2dFN($val);
                         }
                     }
                 }
                 if (!empty($extraArr)) {
                     $returnArr[$table] = $extraArr;
                 }
             }
         }
     }
     return $returnArr;
 }