Пример #1
0
 /**
  * Creates a tracks individual for the user
  * Method is called after user data is stored in the database
  *
  * @param   array    $user     holds the new user data
  * @param   boolean  $isnew    true if a new user is stored
  * @param   boolean  $success  true if user was succesfully stored in the database
  * @param   string   $msg      message
  *
  * @return void
  */
 public function onUserAfterSave($user, $isnew, $success, $msg)
 {
     $app = JFactory::getApplication();
     // Require tracks individual table
     require_once JPATH_ADMINISTRATOR . '/components/com_tracks/tables/individual.php';
     if ($isnew) {
         $table = RTable::getAdminInstance('Individual', array(), 'com_tracks');
         if ($this->params->get('map_name', 0) == 0) {
             $split = strpos($user['name'], ' ');
             if ($split && $this->params->get('split_name', 1)) {
                 $table->first_name = substr($user['name'], 0, $split);
                 $table->last_name = substr($user['name'], $split + 1);
             } else {
                 $table->last_name = $user['name'];
             }
         } else {
             $table->last_name = $user['username'];
         }
         switch ($this->params->get('map_nickname', 2)) {
             case 0:
                 break;
             case 1:
                 $table->nickname = $user['name'];
                 break;
             case 2:
                 $table->nickname = $user['username'];
                 break;
         }
         $table->user_id = $user['id'];
         if ($table->check() && $table->store()) {
         } else {
             Jerror::raiseWarning(0, JText::_('Error_while_creating_tracks_individual'));
         }
     }
 }
Пример #2
0
 /**
  * Deep copy with rounds and subrounds
  *
  * @param   array  $cid  project ids
  *
  * @return void
  */
 public function copy($cid)
 {
     foreach ($cid as $projectId) {
         $project = RTable::getAdminInstance('Project');
         $project->load($projectId);
         $newProject = clone $project;
         $newProject->id = null;
         $newProject->name = JText::sprintf('COM_TRACKS_PROJECT_COPY_OF_S', $project->name);
         $newProject->store();
         $this->copyProjectRounds($projectId, $newProject->id);
     }
 }
Пример #3
0
 /**
  * Delete project round events
  *
  * @param   mixed  $pk  An optional primary key value to delete.  If not set the instance property value is used.
  *
  * @return  boolean  True on success.
  */
 protected function deleteProjectroundEvents($pk)
 {
     $pks = $this->getPkArray($pk);
     $pks = implode(', ', RHelperArray::quote($pks));
     $query = $this->_db->getQuery(true)->select('id')->from('#__tracks_events')->where('projectround_id IN (' . $pks . ')');
     $this->_db->setQuery($query);
     $eventIds = $this->_db->loadColumn();
     $table = RTable::getAdminInstance('Event');
     foreach ($eventIds as $id) {
         $table->delete((int) $id);
     }
     return true;
 }
Пример #4
0
 /**
  * Copy events from one project round to the other
  *
  * @param   array  $cid          ids of events to copy
  * @param   int    $destination  destination project round id
  *
  * @return void
  */
 public function copy($cid, $destination)
 {
     if (empty($cid)) {
         return;
     }
     foreach ($cid as $id) {
         $event = RTable::getAdminInstance('Event');
         $event->load($id);
         $new = clone $event;
         $new->id = null;
         $new->projectround_id = $destination;
         $new->store();
     }
 }
Пример #5
0
 /**
  * Copy rounds from one project to the other
  *
  * @param   array  $cid          ids of rounds to copy
  * @param   int    $destination  destination project id
  *
  * @return void
  */
 public function copy($cid, $destination)
 {
     if (empty($cid)) {
         return;
     }
     foreach ($cid as $projectRoundId) {
         $projectRound = RTable::getAdminInstance('Projectround');
         $projectRound->load($projectRoundId);
         $new = clone $projectRound;
         $new->id = null;
         $new->project_id = $destination;
         $new->store();
         $this->copyEvents($projectRoundId, $new->id);
     }
 }
Пример #6
0
 /**
  * Get the associated table
  *
  * @param   string  $name  Main name of the Table. Example: Article for ContentTableArticle
  *
  * @return  RTable
  */
 protected function getTable($name = null)
 {
     if (null === $name) {
         $class = get_class($this);
         $name = strstr($class, 'Entity');
     }
     $name = str_replace('Entity', '', $name);
     return RTable::getAdminInstance($name, array(), $this->getComponent());
 }