Esempio n. 1
0
 /**
  * List all groups
  * @since Version 3.5
  * @param int $maxLevel
  */
 public function getGroups($maxLevel = 0)
 {
     $query = "SELECT g.group_id AS id, g.organisation_id, g.group_name AS name, g.group_type AS type, g.group_description AS description, \r\n                    g.group_attrs, g.group_moderator AS owner_user_id, u.username AS owner_username \r\n                FROM nuke_bbgroups AS g \r\n                    INNER JOIN nuke_users AS u ON g.group_moderator = u.user_id \r\n                WHERE g.group_single_user = 0 \r\n                    AND g.group_type <= ? ORDER BY g.group_name";
     $return = array();
     foreach ($this->db->fetchAll($query, $maxLevel) as $row) {
         $row['group_attrs'] = !empty($row['group_attrs']) ? json_decode($row['group_attrs'], true) : array();
         if (filter_var($row['organisation_id'], FILTER_VALIDATE_INT)) {
             $Organisation = OrganisationsFactory::CreateOrganisation($row['organisation_id']);
             $row['organisation_name'] = $Organisation->name;
         }
         ksort($row);
         $return[$row['id']] = $row;
     }
     return $return;
 }
Esempio n. 2
0
 /**
  * Populate this object
  * @since Version 3.9.1
  * @return void
  * @param int|string $id
  */
 private function populate($id)
 {
     $row = $this->load($id);
     if (!isset($row) || !is_array($row)) {
         return;
     }
     $this->title = $row['title'];
     $this->desc = $row['description'];
     $this->meta = json_decode($row['meta'], true);
     $this->slug = $row['slug'];
     $this->status = isset($row['status']) ? $row['status'] : Events::STATUS_APPROVED;
     if (!isset($row['user_id'])) {
         $row['user_id'] = 45;
     }
     $this->setAuthor(UserFactory::CreateUser($row['user_id']));
     $this->flickr_tag = "railpage:event=" . $this->id;
     if (filter_var($row['category_id'], FILTER_VALIDATE_INT)) {
         $this->Category = Factory::CreateEventCategory($row['category_id']);
     }
     if (filter_var($row['organisation_id'], FILTER_VALIDATE_INT)) {
         $this->Organisation = OrganisationsFactory::CreateOrganisation($row['organisation_id']);
     }
     if (!empty($row['lat']) && round($row['lat'], 3) != "0.000" && !empty($row['lon']) && round($row['lon'], 3) != "0.000") {
         $this->Place = Place::Factory($row['lat'], $row['lon']);
     }
     $this->createUrls();
     $this->Templates = new stdClass();
     $this->Templates->view = sprintf("%s/event.tpl", $this->Module->Paths->html);
 }
Esempio n. 3
0
 /**
  * Populate this object
  * @since Version 3.9.1
  * @return void
  */
 private function load()
 {
     if (filter_var($this->id, FILTER_VALIDATE_INT)) {
         $this->mckey = sprintf("railpage:timetable.train=%d", $this->id);
         if (!($row = $this->Memcached->fetch($this->mckey))) {
             $query = "SELECT * FROM timetable_trains WHERE id = ?";
             $row = $this->db->fetchRow($query, $ithis->d);
             $this->Memcached->save($this->mckey, $row);
         }
     }
     if (isset($row)) {
         $this->number = $row['train_number'];
         $this->meta = json_decode($row['meta'], true);
         $this->provider = $row['provider'];
         $this->commodity = $row['commodity'];
         if ($row['operator_id'] > 0) {
             $this->Organisation = OrganisationsFactory::CreateOrganisation($row['operator_id']);
         }
         $this->url = new Url(sprintf("%s/t/%s/%s", $this->Module->url, $this->provider, strtolower($this->number)));
         $this->url->edit = sprintf("%s?mode=edit", $this->url->url);
     }
 }
Esempio n. 4
0
 /**
  * Populate this object
  * @since Version 3.5
  * @return boolean
  */
 public function fetch()
 {
     $mckey = sprintf("railpage:group=%d", intval($this->id));
     if (!($row = $this->Redis->fetch($mckey))) {
         $query = "SELECT g.group_attrs, g.organisation_id, g.group_id AS id, g.group_name AS name, g.group_type AS type, \r\n                        g.group_description AS description, g.group_moderator AS owner_user_id, u.username AS owner_username \r\n                    FROM nuke_bbgroups AS g \r\n                        INNER JOIN nuke_users AS u ON g.group_moderator = u.user_id \r\n                    WHERE g.group_id = ?";
         $row = $this->db->fetchRow($query, $this->id);
         $this->Redis->save($mckey, $row, 0);
     }
     if (!is_array($row)) {
         throw new Exception("Could not fetch group data for group ID " . $this->id);
     }
     $this->name = $row['name'];
     $this->type = $row['type'];
     $this->desc = $row['description'];
     $this->owner_user_id = $row['owner_user_id'];
     $this->owner_username = $row['owner_username'];
     $this->attributes = json_decode($row['group_attrs'], true);
     if (filter_var($row['organisation_id'], FILTER_VALIDATE_INT) && $row['organisation_id'] !== 0) {
         $Organisation = OrganisationsFactory::CreateOrganisation(false, $this->organisation_id);
         if ($Organisation instanceof Organisation) {
             $this->organisation_id = $row['organisation_id'];
             $this->organisation = $Organisation->name;
         }
     }
     $this->makeURLs();
 }
Esempio n. 5
0
 /**
  * Get all job providers
  *
  * @since Version 3.9
  * @return \Railpage\Organisations\Organisation
  * @yield \Railpage\Organisations\Organisation
  */
 public function yieldProviders()
 {
     $query = "SELECT jn.organisation_id FROM jn_jobs AS jn LEFT JOIN `organisation` AS o ON o.organisation_id = jn.organisation_id GROUP BY jn.organisation_id ORDER BY organisation_name";
     foreach ($this->db->fetchAll($query) as $row) {
         (yield OrganisationsFactory::CreateOrganisation($row['organisation_id']));
     }
 }
Esempio n. 6
0
 /**
  * Populate this object
  * @since Version 3.9.1
  * @return void
  */
 private function populate()
 {
     $query = "SELECT organisation_id, conversions, job_added, reference_id, job_urls, job_location_id, job_classification_id, job_thread_id, job_title, job_description, job_expiry, DATEDIFF(job_expiry, NOW()) AS job_expiry_until, job_salary, job_special_cond, job_duration FROM jn_jobs WHERE job_id = ?";
     if (!($result = $this->Memcached->fetch($this->mckey))) {
         $result = $this->db->fetchRow($query, $this->id);
         $this->Memcached->save($this->mckey, $result, strtotime("+ week"));
     }
     $this->title = $result['job_title'];
     $this->desc = $result['job_description'];
     $this->expiry = $this->expiry = new DateTime($result['job_expiry']);
     $this->expiry_until = (new DateTime())->diff($this->expiry)->format("%a");
     $this->salary = $result['job_salary'];
     $this->special_cond = $result['job_special_cond'];
     $this->duration = $result['job_duration'];
     $this->reference_id = $result['reference_id'];
     $this->conversions = $result['conversions'];
     if (empty($this->duration) || $this->duration === 0) {
         $this->duration = "Ongoing";
     }
     if ($result['job_added'] != "0000-00-00 00:00:00") {
         $this->Open = new DateTime($result['job_added']);
     }
     $this->Organisation = OrganisationsFactory::CreateOrganisation($result['organisation_id']);
     $this->Location = new Location($result['job_location_id']);
     $this->Classification = new Classification($result['job_classification_id']);
     $this->url = new Url(sprintf("%s/%d", $this->Module->url, $this->id));
     $this->url->conversion = sprintf("%s?apply", $this->url->url);
     if (is_array(json_decode($result['job_urls'], true))) {
         foreach (json_decode($result['job_urls'], true) as $title => $link) {
             if (!is_null($link)) {
                 $this->url->{$title} = $link;
             }
         }
     }
 }