Ejemplo n.º 1
0
 /**
  * logic to create the edit venue view
  *
  * @access public
  * @return void
  * @since 0.9
  */
 function edit()
 {
     JRequest::setVar('view', 'settings');
     parent::display();
     $model = $this->getModel('settings');
     $model->checkout();
 }
Ejemplo n.º 2
0
 /**
  * logic to create the edit event screen
  *
  * @access public
  * @return void
  * @since 0.9
  */
 function edit()
 {
     JRequest::setVar('view', 'group');
     JRequest::setVar('hidemainmenu', 1);
     $model = $this->getModel('group');
     $user =& JFactory::getUser();
     // Error if checkedout by another administrator
     if ($model->isCheckedOut($user->get('id'))) {
         $this->setRedirect('index.php?option=com_eventlist&view=groups', JText::_('EDITED BY ANOTHER ADMIN'));
     }
     $model->checkout();
     parent::display();
 }
Ejemplo n.º 3
0
 function csvcategoriesimport()
 {
     $replace = JRequest::getVar('replace_cats', 0, 'post', 'int');
     $object =& JTable::getInstance('eventlist_categories', '');
     $object_fields = get_object_vars($object);
     $msg = '';
     if ($file = JRequest::getVar('Filecats', null, 'files', 'array')) {
         $handle = fopen($file['tmp_name'], 'r');
         if (!$handle) {
             $msg = JText::_('Cannot open uploaded file.');
             $this->setRedirect('index.php?option=com_eventlist&view=import', $msg, 'error');
             return;
         }
         // get fields, on first row of the file
         $fields = array();
         if (($data = fgetcsv($handle, 1000, ',', '"')) !== FALSE) {
             $numfields = count($data);
             for ($c = 0; $c < $numfields; $c++) {
                 // here, we make sure that the field match one of the fields of eventlist_venues table or special fields,
                 // otherwise, we don't add it
                 if (array_key_exists($data[$c], $object_fields)) {
                     $fields[$c] = $data[$c];
                 }
             }
         }
         // If there is no validated fields, there is a problem...
         if (!count($fields)) {
             $msg .= "<p>Error parsing column names. Are you sure this is a proper csv export ?<br />try to export first to get an example of formatting</p>\n";
             $this->setRedirect('index.php?option=com_eventlist&view=import', $msg, 'error');
             return;
         } else {
             $msg .= "<p>" . $numfields . " fields found in first row</p>\n";
             $msg .= "<p>" . count($fields) . " fields were kept</p>\n";
         }
         // Now get the records, meaning the rest of the rows.
         $records = array();
         $row = 1;
         while (($data = fgetcsv($handle, 10000, ',', '"')) !== FALSE) {
             $num = count($data);
             if ($numfields != $num) {
                 $msg .= "<p>Wrong number of fields ({$num}) line {$row}<br /></p>\n";
             } else {
                 $r = array();
                 // only extract columns with validated header, from previous step.
                 foreach ($fields as $k => $v) {
                     $r[] = $this->_formatcsvfield($v, $data[$k]);
                 }
                 $records[] = $r;
             }
             $row++;
         }
         fclose($handle);
         $msg .= "<p>total records found: " . count($records) . "<br /></p>\n";
         // database update
         if (count($records)) {
             $model = $this->getModel('import');
             $result = $model->categoriesimport($fields, $records, $replace);
             $msg .= "<p>total added records: " . $result['added'] . "<br /></p>\n";
             $msg .= "<p>total updated records: " . $result['updated'] . "<br /></p>\n";
         }
         $this->setRedirect('index.php?option=com_eventlist&view=import', $msg);
     } else {
         parent::display();
     }
 }