コード例 #1
0
ファイル: files.php プロジェクト: atikahmed/joomla-probid
 function save()
 {
     $row =& JTable::getInstance('RSMembership_Files', 'Table');
     $post = JRequest::get('post');
     if (!empty($post['thumb_delete'])) {
         $post['thumb'] = '';
     }
     // Thumbnail width must not be less than 1px
     $post['thumb_w'] = (int) $post['thumb_w'];
     if ($post['thumb_w'] <= 0) {
         $post['thumb_w'] = 48;
     }
     // These elements are not filtered for HTML code
     $post['description'] = JRequest::getVar('description', '', 'post', 'none', JREQUEST_ALLOWRAW);
     if (!$row->bind($post)) {
         return JError::raiseWarning(500, $row->getError());
     }
     unset($row->thumb);
     if ($row->store()) {
         $this->_id = $row->path;
         // Process the thumbnail
         $files = JRequest::get('files');
         $thumb = $files['thumb'];
         jimport('joomla.filesystem.file');
         $thumb['db_name'] = JPATH_ROOT . DS . 'components' . DS . 'com_rsmembership' . DS . 'assets' . DS . 'thumbs' . DS . 'files' . DS . $row->id;
         // Delete it if requested
         if (!empty($post['thumb_delete'])) {
             JFile::delete($thumb['db_name'] . '.jpg');
         }
         // Add the thumbnail if uploaded
         if (!$thumb['error'] && !empty($thumb['tmp_name'])) {
             // Resize the thumb if requested
             if (!empty($post['thumb_resize'])) {
                 $success = RSMembershipHelper::createThumb($thumb['tmp_name'], $thumb['db_name'], $row->thumb_w);
             } else {
                 $success = JFile::upload($thumb['tmp_name'], $thumb['db_name'] . '.jpg');
             }
             // Add to database only if upload successful
             if ($success) {
                 $this->_db->setQuery("UPDATE #__rsmembership_files SET `thumb`='" . JFile::getName($thumb['db_name'] . '.jpg') . "' WHERE `id`='" . $row->id . "'");
                 $this->_db->query();
             }
         }
         return true;
     } else {
         JError::raiseWarning(500, $row->getError());
         return false;
     }
 }
コード例 #2
0
 function save()
 {
     $row =& JTable::getInstance('RSMembership_Memberships', 'Table');
     $post = JRequest::get('post');
     if (!empty($post['thumb_delete'])) {
         $post['thumb'] = '';
     }
     // Thumbnail width must not be less than 1px
     $post['thumb_w'] = (int) $post['thumb_w'];
     if ($post['thumb_w'] <= 0) {
         $post['thumb_w'] = 48;
     }
     // Periods must be an integer
     $post['period'] = (int) @$post['period'];
     // Stock must be an integer
     $post['stock'] = (int) $post['stock'];
     // These elements are not filtered for HTML code
     $allowed = array('description', 'custom_code', 'custom_code_transaction', 'thankyou', 'redirect', 'share_redirect', 'admin_email_new_text', 'user_email_new_text', 'user_email_approved_text', 'admin_email_approved_text', 'user_email_renew_text', 'admin_email_renew_text', 'user_email_upgrade_text', 'admin_email_upgrade_text', 'user_email_addextra_text', 'admin_email_addextra_text', 'user_email_expire_text', 'admin_email_expire_text');
     foreach ($allowed as $item) {
         $post[$item] = JRequest::getVar($item, '', 'post', 'none', JREQUEST_ALLOWRAW);
     }
     if (!$row->bind($post)) {
         return JError::raiseWarning(500, $row->getError());
     }
     if (empty($row->id)) {
         $row->ordering = $row->getNextOrder();
     }
     unset($row->thumb);
     if ($row->store()) {
         $this->_id = $row->id;
         // Process the thumbnail
         $files = JRequest::get('files');
         $thumb = $files['thumb'];
         jimport('joomla.filesystem.file');
         $thumb['db_name'] = JPATH_ROOT . DS . 'components' . DS . 'com_rsmembership' . DS . 'assets' . DS . 'thumbs' . DS . $row->id;
         // Delete it if requested
         if (!empty($post['thumb_delete'])) {
             JFile::delete($thumb['db_name'] . '.jpg');
             $this->_db->setQuery("UPDATE #__rsmembership_memberships SET `thumb`='' WHERE `id`='" . $row->id . "'");
             $this->_db->query();
         }
         // Add the thumbnail if uploaded
         if (!$thumb['error'] && !empty($thumb['tmp_name'])) {
             // Resize the thumb if requested
             if (!empty($post['thumb_resize'])) {
                 $success = RSMembershipHelper::createThumb($thumb['tmp_name'], $thumb['db_name'], $row->thumb_w);
             } else {
                 $success = JFile::upload($thumb['tmp_name'], $thumb['db_name'] . '.jpg');
             }
             // Add to database only if upload successful
             if ($success) {
                 $this->_db->setQuery("UPDATE #__rsmembership_memberships SET `thumb`='" . JFile::getName($thumb['db_name'] . '.jpg') . "' WHERE `id`='" . $row->id . "'");
                 $this->_db->query();
             }
         }
         // Process the extras
         $extras = $post['extras'];
         JArrayHelper::toInteger($extras, array(0));
         $this->_db->setQuery("DELETE FROM #__rsmembership_membership_extras WHERE `membership_id`='" . $row->id . "'");
         $this->_db->query();
         foreach ($extras as $extra) {
             if (empty($extra)) {
                 continue;
             }
             $this->_db->setQuery("INSERT INTO #__rsmembership_membership_extras SET `membership_id`='" . $row->id . "', `extra_id`='" . $extra . "'");
             $this->_db->query();
         }
         return true;
     } else {
         JError::raiseWarning(500, $row->getError());
         return false;
     }
 }
コード例 #3
0
ファイル: file.php プロジェクト: JozefAB/qk
 public function save($data)
 {
     $row = $this->getTable('File', 'RSMembershipTable');
     $jinput = JFactory::getApplication()->input;
     $jform = $jinput->get('jform', array(), 'array');
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     if (!empty($jform['thumb_delete'])) {
         $jform['thumb'] = '';
     }
     // Thumbnail width must not be less than 1px
     $jform['thumb_w'] = (int) $jform['thumb_w'];
     if ($jform['thumb_w'] <= 0) {
         $jform['thumb_w'] = 48;
     }
     if (!$row->bind($jform)) {
         return JError::raiseWarning(500, $row->getError());
     }
     unset($row->thumb);
     if ($row->store()) {
         // Process the thumbnail
         $files = $jinput->files->get('jform', array(), 'array');
         $thumb = $files['thumb'];
         jimport('joomla.filesystem.file');
         $thumb['db_name'] = JPATH_ROOT . '/components/com_rsmembership/assets/thumbs/files/' . $row->id;
         // Delete the thumbnail if requested
         if (!empty($jform['thumb_delete'])) {
             JFile::delete($thumb['db_name'] . '.jpg');
             $query->clear();
             $query->update($db->qn('#__rsmembership_files'))->set($db->qn('thumb') . ' = ' . $db->q(''))->where($db->qn('id') . ' = ' . $row->id);
             $db->setQuery($query);
             $db->execute();
         }
         // Add the thumbnail if uploaded
         if (!$thumb['error'] && !empty($thumb['tmp_name'])) {
             // Resize the thumb if requested
             if (!empty($jform['thumb_resize'])) {
                 $success = RSMembershipHelper::createThumb($thumb['tmp_name'], $thumb['db_name'], $row->thumb_w);
             } else {
                 $success = JFile::upload($thumb['tmp_name'], $thumb['db_name'] . '.jpg');
             }
             // Add to database only if upload successful
             if ($success) {
                 $query->clear();
                 $query->update($db->qn('#__rsmembership_files'))->set($db->qn('thumb') . ' = ' . $db->q(JFile::getName($thumb['db_name'] . '.jpg')))->where($db->qn('id') . ' = ' . $row->id);
                 $db->setQuery($query);
                 $db->execute();
             }
         }
         return true;
     } else {
         JError::raiseWarning(500, $row->getError());
         return false;
     }
 }
コード例 #4
0
ファイル: membership.php プロジェクト: JozefAB/qk
 public function save($data)
 {
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $post = JFactory::getApplication()->input->get('jform', array(), 'array');
     if (isset($post['period_values'])) {
         $data['period_type'] = $post['period_values'][0];
         $data['period'] = $post['period_values'][1];
     }
     if (isset($post['trial_period_values'])) {
         $data['trial_period_type'] = $post['trial_period_values'][0];
         $data['trial_period'] = $post['trial_period_values'][1];
     }
     if (isset($post['fixed_expiry_values'][3])) {
         $data['fixed_day'] = $post['fixed_expiry_values'][0];
         $data['fixed_month'] = $post['fixed_expiry_values'][1];
         $data['fixed_year'] = $post['fixed_expiry_values'][2];
         $data['fixed_expiry'] = $post['fixed_expiry_values'][3];
     } else {
         $data['fixed_day'] = 0;
         $data['fixed_month'] = 0;
         $data['fixed_year'] = 0;
         $data['fixed_expiry'] = 0;
     }
     if (isset($post['thumb_delete'])) {
         $data['thumb'] = '';
     }
     $data['thumb_w'] = (int) $post['thumb_w'];
     if ($data['thumb_w'] <= 0) {
         $data['thumb_w'] = 48;
     }
     if (parent::save($data)) {
         $data['id'] = $this->getState($this->getName() . '.id');
         // Trigger event
         JFactory::getApplication()->triggerEvent('rsm_onMembershipSave', array(&$data));
         // Process the thumbnail
         $files = JFactory::getApplication()->input->files->get('jform');
         $thumb = $files['thumb'];
         jimport('joomla.filesystem.file');
         $thumb['db_name'] = JPATH_ROOT . '/components/com_rsmembership/assets/thumbs/' . $data['id'];
         // Delete it if requested
         if (isset($post['thumb_delete'])) {
             JFile::delete($thumb['db_name'] . '.jpg');
             $query->clear();
             $query->update($db->qn('#__rsmembership_memberships'))->set($db->qn('thumb') . ' = ' . $db->q(''))->where($db->qn('id') . ' = ' . $data['id']);
             $db->setQuery($query);
             $db->execute();
         }
         // Add the thumbnail if uploaded
         if (!$thumb['error'] && !empty($thumb['tmp_name'])) {
             // Resize the thumb if requested
             if (isset($post['thumb_resize'])) {
                 $success = RSMembershipHelper::createThumb($thumb['tmp_name'], $thumb['db_name'], $data['thumb_w']);
             } else {
                 $success = JFile::upload($thumb['tmp_name'], $thumb['db_name'] . '.jpg');
             }
             // Add to database only if upload successful
             if ($success) {
                 $query->clear();
                 $query->update($db->qn('#__rsmembership_memberships'))->set($db->qn('thumb') . ' = ' . $db->q(JFile::getName($thumb['db_name'] . '.jpg')))->where($db->qn('id') . ' = ' . $data['id']);
                 $db->setQuery($query);
                 $db->execute();
             }
         }
         // Process the extras
         $extras = $data['extras'];
         JArrayHelper::toInteger($extras, array(0));
         $query->clear();
         $query->delete()->from($db->qn('#__rsmembership_membership_extras'))->where($db->qn('membership_id') . ' = ' . $db->q($data['id']));
         $db->setQuery($query);
         $db->execute();
         foreach ($extras as $extra) {
             if (empty($extra)) {
                 continue;
             }
             $query->clear();
             $query->insert($db->qn('#__rsmembership_membership_extras'))->columns(array('membership_id', 'extra_id'))->values($db->q($data['id']) . ', ' . $db->q($extra));
             $db->setQuery($query);
             $db->execute();
         }
         return true;
     } else {
         JError::raiseWarning(500, $this->getError());
         return false;
     }
 }