Exemplo n.º 1
0
 /**
  * Instalation of plugin
  */
 static function install()
 {
     // Create SQL Tables
     CindaQuery::create_tables();
     // Register the DB version for futures modifications
     add_option('CINDA_DATABASE_VERSION', CINDA_DATABASE_VERSION);
     // Redirect to Option page.
     wp_redirect(cinda_options_URL());
 }
Exemplo n.º 2
0
 /**
  * Set model of data from database
  */
 function set_model_from_db()
 {
     $this->model = CindaQuery::get_model($this->ID);
 }
Exemplo n.º 3
0
 function export_contributions($id_campaign)
 {
     $model = \cinda\CindaQuery::get_model($id_campaign);
     if ($model) {
         $this->open();
         foreach ($model as $field) {
             $headers[] = $field->field_name;
         }
         $headers[] = "create_date";
         $headers[] = "author_name";
         // Insert headers to CSV
         fputcsv($this->csv, $headers);
         $contributionList = new ContributionsList($id_campaign);
         $contributions = $contributionList->get_contributions();
         if (0 < count($contributions)) {
             foreach ($contributions as $contribution) {
                 $data = array();
                 foreach ($model as $field) {
                     $name = $field->field_name;
                     if (isset($contribution->data[$name])) {
                         $data[] = htmlentities($contribution->data[$name]);
                     } else {
                         $data[] = "";
                     }
                 }
                 $data[] = $contribution->data['create_date'];
                 $data[] = $contribution->data['author_name'];
                 // Insert row to CSV
                 fputcsv($this->csv, $data);
             }
         }
         $this->close();
     } else {
         return;
     }
 }
Exemplo n.º 4
0
 /**
  * Set model of data from database
  */
 function set_model_from_db($id_campaign)
 {
     $this->model = CindaQuery::get_model($id_campaign);
 }