コード例 #1
0
function aggregator_main()
{
    global $db, $dblang;
    $result = $db->get_results('SELECT * FROM categories c JOIN feed_data f ON f.id = c.category_id WHERE c.category_lang="' . $dblang . '"');
    foreach ($result as $category) {
        aggregator_refresh($category);
    }
}
コード例 #2
0
ファイル: akteure.php プロジェクト: JuliAne/easteasteast
 /** 
  *  Method to write or update an akteur to database
  *  @param $data : akteure-object
  *  @param $defaultAID : integer [optional, required for update-action]
  *  @return $akteurId : integer || $this->fehler : array
  *
  *  TODO: Remove $_POST's
  */
 public function setUpdateAkteur($data, $defaultAID = NULL)
 {
     $this->__setSingleAkteurVars($data);
     // Validate inputs, abort & return $this->fehler if necessary
     if (empty($this->name)) {
         $this->fehler['name'] = t('Bitte einen Organisationsnamen eingeben!');
     }
     if (empty($this->email) || !valid_email_address($this->email)) {
         $this->fehler['email'] = t('Bitte eine (gültige) Emailadresse eingeben!');
     }
     if (empty($this->adresse->bezirk)) {
         $this->fehler['ort'] = t('Bitte einen Bezirk auswählen!');
     }
     if (strlen($this->name) > 64) {
         $this->fehler['name'] = t('Bitte geben Sie einen kürzeren Namen an oder verwenden Sie ein Kürzel.');
     }
     if (strlen($this->email) > 100) {
         $this->fehler['email'] = t('Bitte geben Sie eine kürzere Emailadresse an.');
     }
     if (strlen($this->telefon) > 100) {
         $this->fehler['telefon'] = t('Bitte geben Sie eine kürzere Telefonnummer an.');
     }
     if (strlen($this->url) > 100) {
         $this->fehler['url'] = t('Bitte geben Sie eine kürzere URL an.');
     }
     if (!empty($this->url) && preg_match('/\\A(http:\\/\\/|https:\\/\\/)(\\w*[.|-]\\w*)*\\w+\\.[a-z]{2,3}(\\/.*)*\\z/', $this->url) == 0) {
         $this->fehler['url'] = t('Bitte eine gültige URL zur Akteurswebseite eingeben! (z.B. <i>http://meinakteur.de</i>)');
     }
     if (strlen($this->ansprechpartner) > 100) {
         $this->fehler['ansprechpartner'] = t('Bitte geben Sie einen kürzeren Ansprechpartner an.');
     }
     if (strlen($this->funktion) > 100) {
         $this->fehler['funktion'] = t('Bitte geben Sie eine kürzere Funktion an.');
     }
     if (strlen($this->beschreibung) > 65000) {
         $this->fehler['beschreibung'] = t('Bitte geben Sie eine kürzere Beschreibung an.');
     }
     if (strlen($this->oeffnungszeiten) > 200) {
         $this->fehler['oeffnungszeiten'] = t('Bitte geben Sie kürzere Öffnungszeiten an.');
     }
     if (strlen($this->adresse->strasse) > 100) {
         $this->fehler['strasse'] = t('Bitte geben Sie einen kürzeren Strassennamen an.');
     }
     if (strlen($this->adresse->nr) > 100) {
         $this->fehler['nr'] = t('Bitte geben Sie eine kürzere Hausnummer an.');
     }
     if (strlen($this->adresse->adresszusatz) > 100) {
         $this->fehler['adresszusatz'] = t('Bitte geben Sie einen kürzeren Adresszusatz an.');
     }
     if (strlen($this->adresse->plz) > 100) {
         $this->fehler['plz'] = t('Bitte geben Sie eine kürzere PLZ an.');
     }
     if (strlen($this->adresse->gps) > 100) {
         $this->fehler['gps'] = t('Bitte geben Sie kürzere GPS-Daten an.');
     }
     if (strlen($this->rssFeed) > 400 || preg_match('/\\A(http:\\/\\/|https:\\/\\/)(\\w*[.|-]\\w*)*\\w+\\.[a-z]{2,3}(\\/.*)*\\z/', $this->rssFeed) == 0) {
         # $this->fehler['rssFeed'] = t('Die URL zum RSS-Feed ist zu lang oder ungültig...');
     }
     if ($this->gps == 'Ermittle Geo-Koordinaten...') {
         $this->gps = '';
     }
     if (!empty($this->fehler)) {
         return $this->fehler;
     }
     // ----- INSERT- or UPDATE-Actions --------
     // Wenn Bilddatei ausgewählt wurde...
     if (isset($_FILES['bild']['name']) && !empty($_FILES['bild']['name'])) {
         $this->bild = $this->upload_image($_FILES['bild']);
     } else {
         if (isset($_POST['oldPic'])) {
             $this->bild = $this->clearContent($_POST['oldPic']);
         }
     }
     if ($defaultAID) {
         // = Prepare UPDATE-Action
         $akteurAdress = db_select($this->tbl_akteur, 'a')->fields('a', array('adresse'))->condition('AID', $defaultAID)->execute()->fetchObject();
         $this->adresse->ADID = $akteurAdress->adresse;
         // remove current picture manually
         if (!empty($this->removedPic)) {
             $b = end(explode('/', $this->removedPic));
             if (file_exists($this->short_bildpfad . $b)) {
                 unlink($this->short_bildpfad . $b);
             }
             if ($_POST['oldPic'] == $this->removedPic) {
                 $this->bild = '';
             }
         }
     }
     $this->adresse = $this->adressHelper->setUpdateAdresse($this->adresse);
     $this->akteur_id = $this->__db_action($this->tbl_akteur, array('name' => $this->name, 'adresse' => $this->adresse, 'email' => $this->email, 'telefon' => $this->telefon, 'url' => $this->url, 'ansprechpartner' => $this->ansprechpartner, 'funktion' => $this->funktion, 'bild' => $this->bild, 'beschreibung' => $this->beschreibung, 'oeffnungszeiten' => $this->oeffnungszeiten, 'barrierefrei' => !empty($this->barrierefrei) && ($this->barrierefrei || $this->barrierefrei == 'on') ? 1 : 0), $defaultAID ? array('AID', $defaultAID) : NULL, true);
     if (!$defaultAID) {
         $userHasAkteur = $this->__db_action($this->tbl_hat_user, array('hat_UID' => $this->user_id, 'hat_AID' => $this->akteur_id));
     }
     if (module_exists('aggregator')) {
         if (empty($defaultAID) && !empty($this->rssFeed)) {
             $feed = array('category' => 'aae-feeds', 'title' => 'aae-feed-' . $this->akteur_id, 'description' => t('Feed for AAE-User :username', array(':username' => $this->name)), 'url' => $this->rssFeed, 'refresh' => '86400', 'link' => base_path() . 'akteurprofil/' . $this->akteur_id, 'block' => 0);
             aggregator_save_feed($feed);
             aggregator_refresh($feed);
         } else {
             if (!empty($defaultAID)) {
                 $akteurFeed = db_select('aggregator_feed', 'af')->fields('af', array('fid', 'url'))->condition('title', 'aae-feed-' . $this->akteur_id)->execute();
                 $hasFeed = $akteurFeed->rowCount();
                 $akteurFeed = $akteurFeed->fetchObject();
                 if (!empty($this->rssFeed) && $hasFeed) {
                     // UPDATE-ACTION: Rewrite RSS-path of Feed
                     $feedUpdate = db_update('aggregator_feed')->fields(array('url' => $this->rssFeed))->condition('title', 'aae-feed-' . $this->akteur_id)->execute();
                     // Trunkate all current feed items
                     db_delete('aggregator_item')->condition('fid', $hasFeed);
                 } else {
                     if (!empty($this->rssFeed) && !$hasFeed) {
                         // INSERT-ACTION:
                         $feed = array('category' => 'aae-feeds', 'title' => 'aae-feed-' . $this->akteur_id, 'description' => t('Feed for AAE-User :username', array(':username' => $this->name)), 'url' => $this->rssFeed, 'refresh' => '86400', 'link' => base_path() . 'akteurprofil/' . $this->akteur_id, 'block' => 0);
                         aggregator_save_feed($feed);
                         aggregator_refresh($feed);
                     } else {
                         if (empty($this->rssFeed) && $hasFeed && $akteurFeed->url != $this->rssFeed) {
                             // REMOVE-ACTION
                             db_delete('aggregator_feed')->condition('fid', $akteurFeed->fid)->execute();
                             db_delete('aggregator_item')->condition('fid', $akteurFeed->fid)->execute();
                         }
                     }
                 }
             }
         }
         // END IF update_mode
     }
     // END IF module_exists('aggregator')
     // Update or insert Tags
     $this->tagsHelper->setRemoveTags($this->tags, array('akteur', $this->akteur_id), $this->removedTags);
     // TODO: Check for proper HOOK-call
     if (empty($defaultAID)) {
         // Tell Drupal about new akteurprofil/ID-item
         $parentItem = db_query("SELECT menu_links.mlid\n     FROM {menu_links} menu_links\n     WHERE menu_name = :menu_name AND link_path = :link_path", array(":menu_name" => "navigation", ":link_path" => 'akteure'));
         $plid = $parentItem->fetchObject();
         $item = array('menu_name' => 'navigation', 'weight' => 1, 'link_title' => t('Akteurprofil von !username', array('!username' => $this->name)), 'module' => 'aae_data', 'link_path' => 'akteurprofil/' . $this->akteur_id, 'plid' => $plid->mlid);
         module_invoke_all('hook_akteur_created');
     } else {
         module_invoke_all('hook_akteur_modified');
     }
     return $this->akteur_id;
 }