Ejemplo n.º 1
0
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     JHtml::addIncludePath(JPATH_COMPONENT_SITE . '/helpers/html');
     $this->groups = Gamification\Helper::getGroupsOptions();
     $this->ranks = Gamification\Helper::getRanksOptions();
     // Prepare sorting data
     $this->prepareSorting();
     // Prepare actions
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
 /**
  * Save data into the DB
  *
  * @param array $data The data about item
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  * @throws \UnexpectedValueException
  *
  * @return  int
  */
 public function save($data)
 {
     $id = Joomla\Utilities\ArrayHelper::getValue($data, 'id');
     $title = Joomla\Utilities\ArrayHelper::getValue($data, 'title');
     $context = Joomla\Utilities\ArrayHelper::getValue($data, 'context');
     $groupId = Joomla\Utilities\ArrayHelper::getValue($data, 'group_id', 0, 'int');
     $pointsId = Joomla\Utilities\ArrayHelper::getValue($data, 'points_id', 0, 'int');
     $pointsNumber = Joomla\Utilities\ArrayHelper::getValue($data, 'points_number', 0, 'int');
     $published = Joomla\Utilities\ArrayHelper::getValue($data, 'published', 0, 'int');
     $note = Joomla\Utilities\ArrayHelper::getValue($data, 'note');
     $description = Joomla\Utilities\ArrayHelper::getValue($data, 'description');
     $activityText = Joomla\Utilities\ArrayHelper::getValue($data, 'activity_text');
     $customData = Gamification\Helper::prepareCustomData($data);
     $rewards = Gamification\Helper::prepareRewards($data);
     // Load a record from the database
     $row = $this->getTable();
     /** @var $row GamificationTableAchievement */
     $row->load($id);
     $row->set('title', $title);
     $row->set('context', $context);
     $row->set('custom_data', $customData);
     $row->set('rewards', $rewards);
     $row->set('points_number', $pointsNumber);
     $row->set('points_id', $pointsId);
     $row->set('group_id', $groupId);
     $row->set('published', $published);
     $row->set('note', $note);
     $row->set('description', $description);
     $row->set('activity_text', $activityText);
     $this->prepareTable($row);
     $this->prepareImage($row, $data);
     $row->store(true);
     return $row->get('id');
 }
Ejemplo n.º 3
0
 /**
  * Save data into the DB
  *
  * @param array $data The data about item
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  * @throws \UnexpectedValueException
  *
  * @return  int
  */
 public function save($data)
 {
     $id = ArrayHelper::getValue($data, 'id');
     $title = ArrayHelper::getValue($data, 'title');
     $points = ArrayHelper::getValue($data, 'points_number');
     $pointsId = ArrayHelper::getValue($data, 'points_id');
     $groupId = ArrayHelper::getValue($data, 'group_id');
     $published = ArrayHelper::getValue($data, 'published');
     $note = ArrayHelper::getValue($data, 'note');
     $params = ArrayHelper::getValue($data, 'params', [], 'array');
     $description = ArrayHelper::getValue($data, 'description');
     $activityText = ArrayHelper::getValue($data, 'activity_text');
     $customData = Gamification\Helper::prepareCustomData($data);
     $params = new Registry($params);
     // Load a record from the database
     $row = $this->getTable();
     /** @var $row GamificationTableBadge */
     $row->load($id);
     $row->set('title', $title);
     $row->set('points_number', $points);
     $row->set('points_id', $pointsId);
     $row->set('group_id', $groupId);
     $row->set('published', $published);
     $row->set('note', $note);
     $row->set('description', $description);
     $row->set('activity_text', $activityText);
     $row->set('custom_data', $customData);
     $row->set('params', $params->toString());
     $this->prepareTable($row);
     $this->prepareImage($row, $data);
     $row->store(true);
     return $row->get('id');
 }