Ejemplo n.º 1
0
 function insertNoteForAutoFetchOn()
 {
     $q = new sqlQuery($this->getDbCon());
     $q->query("SELECT * FROM contact_website WHERE feed_auto_fetch = 'Yes' AND website_type <> 'Twitter'");
     if ($q->getNumRows()) {
         $f_feed = new Feed();
         while ($q->fetch()) {
             $do_contact_note = new ContactNotes($this->getDbCon());
             $this->getId($q->getData("idcontact_website"));
             $do_contact = new Contact();
             $do_contact->getId($this->idcontact);
             //print_r($do_contact);
             //exit;
             if (!$do_contact->hasData()) {
                 continue;
             }
             $do_user = $do_contact->getParentUser();
             if (!$do_user->hasData()) {
                 continue;
             }
             //print_r($do_user);
             //exit;
             $website = $q->getData("website");
             $website = (substr(ltrim($website), 0, 7) != 'http://' ? 'http://' : '') . $website;
             $arr_item = array();
             //try {
             $arr_items = $f_feed->retrieveSinceLastFetch($website, $q->getData("idcontact_website"));
             //}catch(Exception $ex){
             //  $f_feed->turnFeedOff($q->getData("idcontact_website"));
             //}
             if (is_array($arr_items)) {
                 foreach ($arr_items as $arr_item) {
                     if ($q->getData("feed_last_fetch") < $arr_item[1]) {
                         $do_contact_note->idcontact = $q->getData("idcontact");
                         $link = "<br /><a href='" . $website . "' target='_blank'>" . _('Back to the Source of the Article') . "</a><br />";
                         $search = array('<br />', '<br>', '<br >', '<br/>');
                         $replace = "\n";
                         $note_content = $arr_item[0];
                         $note_content = nl2br(strip_tags($note_content));
                         $note_content = preg_replace('/(<br[^>]*>\\s*){2,}/', '<br/>', $note_content);
                         $do_contact_note->note = $note_content . $link;
                         //$do_contact_note->note = nl2br(strip_tags(str_replace($search, $replace, $arr_item[0]))).$link;
                         $do_contact_note->date_added = date('Y-m-d');
                         //$do_contact_note->iduser = $do_contact->getIdUser($q->getData("idcontact"));
                         $do_contact_note->iduser = $do_user->iduser;
                         $do_contact_note->type = 'RSS';
                         //$do_contact_note->iduser = 20;
                         //$do_contact_note->iduser = $_SESSION['do_User']->iduser;
                         $do_contact_note->add();
                         $do_wf_rss_feed_import = new WorkFeedRssFeedImport();
                         $do_wf_rss_feed_import->addRssFeed($do_contact_note, $website, $note_content);
                     }
                 }
             }
             $this->feed_last_fetch = time();
             $this->update();
             //$do_contact_note->free();
         }
     }
 }
Ejemplo n.º 2
0
                        $workfeed->addRssFeed($do_contact_note, 'http://twitter.com/' . $user->screen_name, $note_content);
                        $imported[] = $user->id;
                    }
                }
            }
            // Import Notes from followers
            $followers = $ofuz_twitter->userFollowers(true);
            if (is_object($followers) && count($followers->user) > 0) {
                foreach ($followers->user as $user) {
                    // Don't import twice; friends may be followers
                    if (in_array($user->id, $imported)) {
                        continue;
                    }
                    $idcontact = $do_twitter->cronFeedStatus($iduser, $user->id, strtotime($user->status->created_at));
                    if ($idcontact !== false) {
                        $link = '<br /><a href="http://twitter.com/' . $user->screen_name . '" target="_blank">Back to the Source of the Article</a><br />';
                        $note_content = nl2br(strip_tags($user->status->text));
                        $do_contact_note = new ContactNotes();
                        $do_contact_note->idcontact = $idcontact;
                        $do_contact_note->note = $note_content . $link;
                        $do_contact_note->date_added = date('Y-m-d');
                        $do_contact_note->iduser = $iduser;
                        $do_contact_note->add();
                        $workfeed = new WorkFeedRssFeedImport();
                        $workfeed->addRssFeed($do_contact_note, 'http://twitter.com/' . $user->screen_name, $note_content);
                    }
                }
            }
        }
    }
}