Ejemplo n.º 1
0
 public static function createMetadataForListing($listing, $user)
 {
     $structure['METADATA'] = array('activation_date' => array('type' => 'date'), 'expiration_date' => array('type' => 'date'), 'views' => array('type' => 'integer'), 'number_of_pictures' => array('type' => 'integer'), 'approveStatus' => array('type' => 'string'), 'rejectReason' => array('type' => 'string'));
     $structure['METADATA'] = array_merge($structure['METADATA'], parent::getObjectMetaData($listing));
     $listing_user_meta_data = array('group' => array('caption' => array('type' => 'string', 'propertyID' => 'caption')), 'registration_date' => array('type' => 'date'));
     $listing_user_meta_data = array_merge($listing_user_meta_data, parent::getObjectMetaData($user));
     $listing_product_meta_data = array('caption' => array('type' => 'string', 'propertyID' => 'caption'), 'description' => array('type' => 'text', 'propertyID' => 'short_description'));
     $listing_type_meta_data = array('caption' => array('type' => 'string', 'propertyID' => 'listing_type'));
     $structure['METADATA'] = array_merge($structure['METADATA'], array('user' => $listing_user_meta_data, 'product' => $listing_product_meta_data, 'type' => $listing_type_meta_data));
     return $structure['METADATA'];
 }
Ejemplo n.º 2
0
 /**
  * Create structure for templates
  * 
  * @param SJB_NewsArticle $article
  * @return array:
  */
 public static function createTemplateStructureForNewsArticle($article)
 {
     $articleInfo = parent::getObjectInfo($article);
     if (is_null(self::$uploadFileManager)) {
         self::$uploadFileManager = new SJB_UploadFileManager();
     }
     foreach ($article->getProperties() as $property) {
         if ($property->isComplex()) {
             $isPropertyEmpty = true;
             $properties = $property->type->complex->getProperties();
             $properties = is_array($properties) ? $properties : array();
             foreach ($properties as $subProperty) {
                 if (!empty($articleInfo['user_defined'][$property->getID()][$subProperty->getID()]) && is_array($articleInfo['user_defined'][$property->getID()][$subProperty->getID()])) {
                     foreach ($articleInfo['user_defined'][$property->getID()][$subProperty->getID()] as $subValue) {
                         if (!empty($subValue)) {
                             $isPropertyEmpty = false;
                         }
                     }
                 }
             }
             if ($isPropertyEmpty) {
                 $articleInfo['user_defined'][$property->getID()] = '';
             }
         }
     }
     $structure = array('sid' => $articleInfo['system']['id'], 'id' => $articleInfo['system']['id'], 'date' => $articleInfo['system']['date'], 'expiration_date' => $articleInfo['system']['expiration_date'], 'active' => $articleInfo['system']['active'], 'image_link' => self::$uploadFileManager->getUploadedFileLink($articleInfo['system']['image']));
     if (!empty($articleInfo['system']['subuser_sid'])) {
         $structure['subuser'] = SJB_UserManager::getUserInfoBySID($articleInfo['system']['subuser_sid']);
     }
     $structure['METADATA'] = array('date' => array('type' => 'date'), 'expiration_date' => array('type' => 'date'));
     $structure = array_merge($structure, $articleInfo['user_defined']);
     $structure['METADATA'] = array_merge($structure['METADATA'], parent::getObjectMetaData($article));
     return array_merge($structure, $articleInfo['user_defined']);
 }
Ejemplo n.º 3
0
 /**
  * 
  * @param SJB_User $user
  */
 public static function createTemplateStructureForUser($user)
 {
     if (!$user) {
         return array();
     }
     $structure = $user->getUserInfo();
     if (SJB_MemoryCache::has('userGroupInfo' . $user->getUserGroupSID())) {
         $user_group_info = SJB_MemoryCache::get('userGroupInfo' . $user->getUserGroupSID());
     } else {
         $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user->getUserGroupSID());
         SJB_MemoryCache::set('userGroupInfo' . $user->getUserGroupSID(), $user_group_info);
     }
     foreach ($user->getProperties() as $property) {
         $value = $property->getValue();
         if ($property->getType() == 'list') {
             $listValues = isset($property->type->property_info['list_values']) ? $property->type->property_info['list_values'] : array();
             foreach ($listValues as $listValue) {
                 if ($listValue['id'] == $value) {
                     $structure[$property->getID()] = $listValue['caption'];
                 }
             }
         } elseif ($property->getType() == 'location') {
             foreach ($property->type->fields as $locationField) {
                 if (isset($structure[$property->getID()]) && array_key_exists($locationField['id'], $structure[$property->getID()])) {
                     if ($locationField['id'] == 'State') {
                         $displayAs = !empty($locationField['display_as']) ? $locationField['display_as'] : 'state_name';
                         $listValues = SJB_StatesManager::getStateNamesBySid($property->value['State'], $displayAs);
                     } else {
                         $listValues = isset($locationField['list_values']) ? $locationField['list_values'] : array();
                     }
                     foreach ($listValues as $listValue) {
                         if ($listValue['id'] == $value[$locationField['id']]) {
                             $structure[$property->getID()][$locationField['id']] = $listValue['caption'];
                             $structure[$property->getID()][$locationField['id'] . '_Code'] = $listValue['Code'];
                             $structure[$property->getID()][$locationField['id'] . '_Name'] = $listValue['Name'];
                         }
                     }
                 }
             }
         } else {
             $structure[$property->getID()] = $value;
         }
     }
     $structure['id'] = $user->getID();
     $structure['isJobg8'] = strpos($structure['username'], 'jobg8_') !== false;
     $structure['group'] = array('id' => $user_group_info['id'], 'caption' => $user_group_info['name']);
     $subuserInfo = $user->getSubuserInfo();
     if (!empty($subuserInfo)) {
         $structure['subuser'] = $subuserInfo;
     }
     $structure['METADATA'] = array('group' => array('caption' => array('type' => 'string', 'propertyID' => 'caption')), 'registration_date' => array('type' => 'date'));
     $structure['METADATA'] = array_merge($structure['METADATA'], parent::getObjectMetaData($user));
     return $structure;
 }