Пример #1
0
 /**
  * Loads some data
  */
 public function _load_object($handler_id, $args, &$data)
 {
     $qb = fi_opengov_datacatalog_dataset_dba::new_query_builder();
     switch ($handler_id) {
         case 'view':
         case 'edit':
         case 'delete':
             if (isset($args[0])) {
                 $this->_show_list = false;
                 $qb->add_constraint('guid', '=', $args[0]);
             }
             break;
     }
     $this->_datasets = $qb->execute();
     switch ($handler_id) {
         case 'open':
             $this->_filter_datasets('open');
             break;
         case 'closed':
             $this->_filter_datasets('closed');
             break;
     }
     if (count($this->_datasets)) {
         if (isset($args[0]) && ($handler_id == 'view' || $handler_id == 'edit' || $handler_id == 'delete')) {
             /* set _object if we want to work on a particular dataset */
             $this->_object = $this->_datasets[0];
         }
     } else {
         /* display no dataset recorded style */
     }
 }
Пример #2
0
 /**
  * Checks the license type of the dataset
  * @param GUID guid of the dataset
  * @param string type; can be free or non-free
  * @return boolean true, if the dataset license type macthes the given criteria
  */
 public function matching_license_type($dataset_guid, $type)
 {
     $retval = false;
     $qb = fi_opengov_datacatalog_dataset_dba::new_query_builder();
     $qb->add_constraint('guid', '=', $dataset_guid);
     $res = $qb->execute();
     if (count($res) == 1) {
         $qb = fi_opengov_datacatalog_info_dba::new_query_builder();
         $qb->add_constraint('id', '=', $res[0]->license);
         $qb->add_constraint('type', '=', 'license');
         $res = $qb->execute();
         if (count($res) == 1) {
             if ($res[0]->get_parameter('fi.opengov.datacatalog', 'license_type') == $type) {
                 $retval = true;
             }
         }
     }
     unset($qb);
     unset($res);
     return $retval;
 }
Пример #3
0
 /**
  * Get latest 'n' comments that are posted to blogs
  * @param string GUID of the blog topic
  * @param integer the last 'n' number of comments to be fetched 
  */
 public function _get_last_dataset_comments($number = -1)
 {
     $_comments = array();
     $qb = fi_opengov_datacatalog_dataset_dba::new_query_builder();
     $_res = $qb->execute();
     foreach ($_res as $dataset) {
         $qb2 = net_nehmer_comments_comment::new_query_builder();
         $qb2->add_constraint('status', '>=', 4);
         $qb2->add_constraint('objectguid', '=', $dataset->guid);
         $_res2 = $qb2->execute();
         if (count($_res2)) {
             foreach ($_res2 as $comment) {
                 $_comments[$comment->metadata->created]['type'] = 'dataset';
                 $_comments[$comment->metadata->created]['object'] = $comment;
             }
             krsort($_comments);
         }
     }
     if (isset($number) && $number != -1 && count($_comments) > $number) {
         $_comments = array_splice($_comments, 0, $number);
     }
     return $_comments;
 }