public static function save()
 {
     JCommentsSecurity::checkToken();
     $task = JCommentsInput::getVar('task');
     $id = (int) JCommentsInput::getVar('id', 0);
     require_once JCOMMENTS_TABLES . '/subscription.php';
     $db = JCommentsFactory::getDBO();
     $row = new JCommentsTableSubscription($db);
     if ($id) {
         $row->load($id);
     }
     $row->object_id = (int) JCommentsInput::getVar('object_id');
     $row->object_group = JCommentsSecurity::clearObjectGroup(JCommentsInput::getVar('object_group'));
     $row->name = preg_replace("/[\\'\"\\>\\<\\(\\)\\[\\]]?+/i", '', strip_tags(JCommentsInput::getVar('name')));
     $row->email = trim(strip_tags(JCommentsInput::getVar('email')));
     $row->published = (int) JCommentsInput::getVar('published');
     if (!$row->id) {
         $query = "SELECT id, name FROM #__users WHERE email = " . $db->Quote($row->email);
         $db->setQuery($query);
         $users = $db->loadObjectList();
         if (count($users)) {
             $row->userid = $users[0]->id;
             $row->name = $users[0]->name;
         } else {
             $row->userid = 0;
         }
         $row->lang = '';
         // TODO: add language selection if JoomFish installed
     }
     $row->store();
     switch ($task) {
         case 'subscription.apply':
             JCommentsRedirect(JCOMMENTS_INDEX . '?option=com_jcomments&task=subscription.edit&hidemainmenu=1&cid[]=' . $row->id);
             break;
         case 'subscription.save':
         default:
             JCommentsRedirect(JCOMMENTS_INDEX . '?option=com_jcomments&task=subscriptions');
             break;
     }
 }