Esempio n. 1
0
 /**
 	Will set the 'display_in_search' field according to business-logic per object type
 	// kuser | kshow | entry
 	// for objects that are search worthy - search_text will hold text from relevant columns depending on the object type 
 */
 public static function setDisplayInSearch(BaseObject $obj, $parent_obj = null)
 {
     if ($obj == null) {
         return;
     }
     // update the displayInSearch with the logic above only when the object is new or null
     if ($obj->isNew() || $obj->getDisplayInSearch() === null) {
         $res = myPartnerUtils::shouldDisplayInSearch($obj->getPartnerId());
         $obj_id = $obj->getId();
         if ($obj_id && is_numeric($obj_id)) {
             self::setRes($res, $obj_id > entry::MINIMUM_ID_TO_DISPLAY);
         }
         if ($res) {
             if ($obj instanceof kuser) {
                 // if the status is not
                 self::setRes($res, $obj->getStatus() == KuserStatus::ACTIVE);
             } elseif ($obj instanceof kshow) {
                 self::setRes($res, $obj->getViewPermissions() == kshow::KSHOW_PERMISSION_EVERYONE || $obj->getViewPermissions() == null);
                 // if the viewPermission changed from kshow::KSHOW_PERMISSION_EVERYONE to something else
                 // update all entries
                 if ($res && $obj->isColumnModified(kshowPeer::VIEW_PERMISSIONS)) {
                     $entries = $obj->getentrys();
                     foreach ($entries as $entry) {
                         // run this code for each entry
                         self::setDisplayInSearch($entry, $obj);
                     }
                 }
             } elseif ($obj instanceof entry) {
                 // status=READY , type=MEDIACLIP, view permissions of kshow
                 self::setRes($res, true);
             } else {
                 throw new Exception("mySearchUtils::setDisplayInSearch - cannot handle objects of type " . get_class($obj));
             }
         }
         $obj->setDisplayInSearch($res);
     } else {
         // if not new - use the value from the object
         $res = $obj->getDisplayInSearch();
     }
     //	echo __METHOD__ . " (" . get_class ( $obj ) . ") res [$res]\n";
     $words = "";
     $fields_to_use = $obj->getColumnNames();
     foreach ($fields_to_use as $field) {
         $field_str = $obj->getByName($field, BasePeer::TYPE_FIELDNAME);
         //  call_user_func ( array ( $obj , $func_name ) );
         $words .= " " . $field_str;
     }
     $extra_invisible_data = null;
     if ($obj instanceof kshow) {
         $type = $obj->getType();
         if (empty($type)) {
             $type = kshow::KSHOW_TYPE_OTHER;
         }
         // add the category to the search
         $words .= " _CAT_" . $type;
     } elseif ($obj instanceof entry) {
         $extra_invisible_data = "_MEDIA_TYPE_" . $obj->getMediaType();
         $type = $obj->getType();
         // add the SEARCH_ENTRY_TYPE_RC to the words
         if ($type == entryType::MIX) {
             $extra_invisible_data .= " " . self::SEARCH_ENTRY_TYPE_RC;
         }
     }
     $prepared_text = self::prepareSearchText($words);
     $partner_id = $obj->getPartnerId();
     // if res == 1 - only for partner , if == 2 - also for kaltura network
     $obj->setSearchText(self::addPartner($partner_id, $prepared_text, $res, $extra_invisible_data));
 }
 /**
 	Will set the 'display_in_search' field according to business-logic per object type
 	// kuser | kshow | entry
 	// for objects that are search worthy - search_text will hold text from relevant columns depending on the object type 
 */
 public static function setDisplayInSearch(BaseObject $obj, $parent_obj = null)
 {
     if ($obj == null) {
         return;
     }
     // update the displayInSearch with the logic above only when the object is new or null
     if ($obj->isNew() || $obj->getDisplayInSearch() === null) {
         $res = myPartnerUtils::shouldDisplayInSearch($obj->getPartnerId());
         $obj_id = $obj->getId();
         if ($obj_id && is_numeric($obj_id)) {
             self::setRes($res, $obj_id > entry::MINIMUM_ID_TO_DISPLAY);
         }
         if ($res) {
             if ($obj instanceof kuser) {
                 // if the status is not
                 self::setRes($res, $obj->getStatus() == KuserStatus::ACTIVE);
             } elseif ($obj instanceof kshow) {
                 self::setRes($res, $obj->getViewPermissions() == kshow::KSHOW_PERMISSION_EVERYONE || $obj->getViewPermissions() == null);
                 // if the viewPermission changed from kshow::KSHOW_PERMISSION_EVERYONE to something else
                 // update all entries
                 if ($res && $obj->isColumnModified(kshowPeer::VIEW_PERMISSIONS)) {
                     $entries = $obj->getentrys();
                     foreach ($entries as $entry) {
                         // run this code for each entry
                         self::setDisplayInSearch($entry, $obj);
                     }
                 }
             } elseif ($obj instanceof entry) {
                 // status=READY , type=MEDIACLIP, view permissions of kshow
                 self::setRes($res, true);
             } else {
                 throw new Exception("mySearchUtils::setDisplayInSearch - cannot handle objects of type " . get_class($obj));
             }
         }
         $obj->setDisplayInSearch($res);
     }
 }