Example #1
0
 public static function FetchFromAssoc($assoc)
 {
     global $link_to_article_images;
     global $link_to_service_images;
     global $my_cache;
     $ob = new self();
     if (ArrayElemIsValidStr($assoc, 'id')) {
         $ob->SetID($assoc['id']);
     }
     if (ArrayElemIsValidStr($assoc, 'author_id')) {
         $ob->SetAuthorID($assoc['author_id']);
     }
     if (ArrayElemIsValidStr($assoc, 'name')) {
         $ob->SetName($assoc['name']);
     }
     if (ArrayElemIsValidStr($assoc, 'annotation')) {
         $ob->SetAnnotation($assoc['annotation']);
     }
     if (ArrayElemIsValidStr($assoc, 'text_block')) {
         $ob->SetTextBlock($assoc['text_block']);
     }
     try {
         if (ArrayElemIsValidStr($assoc, 'creating_date')) {
             $ob->SetCreatingDate(strtotime($assoc['creating_date']));
         }
     } catch (Exception $e) {
         $ob->SetCreatingDate($assoc['creating_date']);
     }
     if (ArrayElemIsValidStr($assoc, 'language')) {
         $ob->SetLanguage($assoc['language']);
         global $image_extensions;
         $ob->SetPathToImage(PathToImage($link_to_article_images . $ob->GetID(), 'cover', $link_to_service_images . 'Logo.png', $image_extensions, $assoc['language']));
     } else {
         $ob->SetLanguage(GetLanguage());
         $ob->SetPathToImage(PathToImage($link_to_article_images . $ob->GetID(), 'cover', $link_to_service_images . 'Logo.png'));
     }
     return $ob;
 }
Example #2
0
 public static function FetchFromAssoc($assoc)
 {
     global $link_to_users_images;
     $ob = new self();
     if (ArrayElemIsValidStr($assoc, 'id')) {
         $ob->SetID($assoc['id']);
     }
     if (ArrayElemIsValidStr($assoc, 'name')) {
         $ob->SetName($assoc['name']);
     }
     if (ArrayElemIsValidStr($assoc, 'surname')) {
         $ob->SetSurname($assoc['surname']);
     }
     if (ArrayElemIsValidStr($assoc, 'fathername')) {
         $ob->SetFathername($assoc['fathername']);
     }
     if (ArrayElemIsValidStr($assoc, 'login')) {
         $ob->SetLogin($assoc['login']);
     }
     if (ArrayElemIsValidStr($assoc, 'password')) {
         $ob->SetPassword($assoc['password']);
     }
     if (ArrayElemIsValidStr($assoc, 'position')) {
         $ob->SetPosition($assoc['position']);
     }
     if (isset($assoc['received_reports'])) {
         if (is_string($assoc['received_reports'])) {
             if ($assoc['received_reports'] === '') {
                 $ob->received_reports = [];
             } else {
                 $ob->SetReceivedReports(json_decode($assoc['received_reports']));
             }
         } else {
             if ($assoc['received_reports'] != NULL) {
                 $ob->SetReceivedReports($assoc['received_reports']);
             } else {
                 $ob->received_reports = [];
             }
         }
     } else {
         $ob->received_reports = [];
     }
     if (isset($assoc['sended_reports'])) {
         if (is_string($assoc['sended_reports'])) {
             if ($assoc['sended_reports'] === '') {
                 $ob->sended_reports = [];
             } else {
                 $ob->SetSendedReports(json_decode($assoc['sended_reports']));
             }
         } else {
             if ($assoc['sended_reports'] != NULL) {
                 $ob->SetSendedReports($assoc['sended_reports']);
             } else {
                 $ob->sended_reports = [];
             }
         }
     } else {
         $ob->sended_reports = [];
     }
     if (ArrayElemIsValidStr($assoc, 'email')) {
         $ob->SetEmail($assoc['email']);
     }
     if (ArrayElemIsValidStr($assoc, 'telephone')) {
         $ob->SetTelephone($assoc['telephone']);
     }
     try {
         if (ArrayElemIsValidStr($assoc, 'last_visit_time')) {
             $ob->SetLastVisitTime(strtotime($assoc['last_visit_time']));
         }
         if (ArrayElemIsValidStr($assoc, 'register_time')) {
             $ob->SetRegisterTime(strtotime($assoc['register_time']));
         }
         if (ArrayElemIsValidStr($assoc, 'birthday')) {
             $ob->SetBirthday(strtotime($assoc['birthday']));
         }
     } catch (Exception $e) {
         $ob->last_visit_time = time_undef;
         $ob->register_time = time_undef;
         $ob->birthday = time_undef;
     }
     if (ArrayElemIsValidStr($assoc, 'id')) {
         $ob->SetPathToPhoto(PathToImage($link_to_users_images . $ob->id, 'avatar', $link_to_users_images . 'common/default_avatar.png'));
     }
     return $ob;
 }