示例#1
0
 private function createFromDBRow($row)
 {
     $user = new User($row[DB::USER_NICKNAME], $row[DB::USER_E_MAIL], $row[DB::USER_PASSWORD]);
     $user->setName($row[DB::USER_NAME])->setSurname($row[DB::USER_SURNAME])->setGender($row[DB::USER_GENDER]);
     if (!is_null($row[DB::USER_BIRTHDAY])) {
         $user->setBirthday(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[DB::USER_BIRTHDAY])));
     }
     $user->setBirthplace($row[DB::USER_BIRTHPLACE])->setLivingPlace($row[DB::USER_LIVINGPLACE])->setHobbies($row[DB::USER_HOBBIES])->setJob($row[DB::USER_JOB])->setRole($row[DB::USER_ROLE])->setVisible($row[DB::USER_VISIBLE])->setID(intval($row[DB::USER_ID]))->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[DB::USER_CREATION_DATE])))->setVerified($row[DB::USER_VERIFIED]);
     try {
         require_once "dao/ResourceDao.php";
         $resourceDao = new ResourceDao();
         $user->setAvatar($resourceDao->quickLoad($row[DB::USER_AVATAR]));
     } catch (Exception $e) {
         //			try {
         //				$user->setAvatar($resourceDao->quickLoad(EMPTY_AVATAR));
         //			} catch (Exception $e1) {
         //				//DEBUG da togliere più avanti, quando ci saranno le immagini.
         //			}
     }
     if ($this->loadDependences) {
         require_once "dao/ContactDao.php";
         $contactDao = new ContactDao();
         $contactDao->loadAll($user);
         require_once "dao/FollowDao.php";
         $followDao = new FollowDao();
         $followDao->loadAllFollowers($user);
         $followDao->loadAllFollows($user);
         require_once "dao/FeedbackDao.php";
         $feedbackDao = new FeedbackDao();
         $feedbackDao->loadAll($user);
     }
     if ($this->loadReports && AuthorizationManager::canUserDo(AuthorizationManager::READ_REPORTS, $user)) {
         require_once 'dao/ReportDao.php';
         $reportDao = new ReportDao();
         $reportDao->loadAll($user);
     }
     //setto lo stato
     $user->setEditable($row[DB::EDITABLE])->setRemovable($row[DB::REMOVABLE]);
     $user->setBlackContent($row[DB::BLACK_CONTENT])->setRedContent($row[DB::RED_CONTENT])->setYellowContent($row[DB::YELLOW_CONTENT])->setAutoBlackContent($row[DB::AUTO_BLACK_CONTENT]);
     if ($this->loadAccessCount) {
         $user->setAccessCount($this->getAccessCount($user));
     }
     return $user;
 }
示例#2
0
 static function resourceExists($resource)
 {
     $resourcedao = new ResourceDao();
     return $resourcedao->exists($resource);
 }