Ejemplo n.º 1
0
 private static function createFromDBManager($db)
 {
     $row = $db->fetch_result();
     define_tables();
     defineUserColumns();
     $data = array(NICKNAME => $row[USER_NICKNAME], EMAIL => $row[USER_E_MAIL], PASSWORD => $row[USER_PASSWORD], NAME => $row[USER_NAME], SURNAME => $row[USER_SURNAME], GENDER => $row[USER_GENDER], BIRTHDAY => date_timestamp_get(date_create($row[USER_BIRTHDAY])), BIRTHPLACE => $row[USER_BIRTHPLACE], LIVING_PLACE => $row[USER_LIVINGPLACE], AVATAR => $row[USER_AVATAR], HOBBIES => $row[USER_HOBBIES], JOB => $row[USER_JOB], ROLE => $row[USER_ROLE], VISIBLE => $row[USER_VISIBLE]);
     $user = new User($data);
     $user->setID(intval($row[USER_ID]))->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[USER_CREATION_DATE])))->setVerified($row[USER_VERIFIED]);
     require_once "common.php";
     $user->setAccessCount(LogManager::getAccessCount("User", $user->getID()));
     return $user;
 }
Ejemplo n.º 2
0
 static function createFromDBResult($row, $loadComments = true)
 {
     if ($row[POST_TYPE] == "news" || $row[POST_TYPE] == "post" || $row[POST_TYPE] == "videoreportage") {
         $content = $row[POST_CONTENT];
     } else {
         $content = unserialize($row[POST_CONTENT]);
     }
     $data = array("title" => $row[POST_TITLE], "subtitle" => $row[POST_SUBTITLE], "headline" => $row[POST_HEADLINE], "author" => intval($row[POST_AUTHOR]), "tags" => $row[POST_TAGS], "categories" => $row[POST_CATEGORIES], "content" => $content, "visible" => $row[POST_VISIBLE] > 0, "type" => $row[POST_TYPE], "place" => $row[POST_PLACE]);
     require_once "post/PostCommon.php";
     require_once "post/collection/Collection.php";
     if ($row[POST_TYPE] == PostType::NEWS) {
         $p = new News($data);
     } else {
         if ($row[POST_TYPE] == PostType::VIDEOREPORTAGE) {
             $p = new VideoReportage($data);
         } else {
             if ($row[POST_TYPE] == PostType::ALBUM) {
                 $p = new Album($data);
             } else {
                 if ($row[POST_TYPE] == PostType::MAGAZINE) {
                     $p = new Magazine($data);
                 } else {
                     if ($row[POST_TYPE] == PostType::PHOTOREPORTAGE) {
                         $p = new PhotoReportage($data);
                     } else {
                         if ($row[POST_TYPE] == PostType::PLAYLIST) {
                             $p = new Playlist($data);
                         } else {
                             if ($row[POST_TYPE] == PostType::COLLECTION) {
                                 $p = new Collection($data);
                             } else {
                                 $p = new Post($data);
                             }
                         }
                     }
                 }
             }
         }
     }
     $p->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[POST_CREATION_DATE])));
     $p->setID(intval($row[POST_ID]));
     if (!is_null($row[POST_MODIFICATION_DATE])) {
         $p->setModificationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[POST_MODIFICATION_DATE])));
     } else {
         $p->setModificationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[POST_CREATION_DATE])));
     }
     if ($loadComments) {
         $p->loadComments();
     }
     $user = Session::getUser();
     if ($user !== false && $user->getRole() == "admin") {
         $p->loadReports();
     }
     $p->setPermalink($row[POST_PERMALINK]);
     require_once "common.php";
     $p->setAccessCount(LogManager::getAccessCount("Post", $p->getID()));
     return $p;
 }