コード例 #1
0
 /**
  * This method is executed when someone sends a comment.
  *
  * @param string             $context
  * @param UserIdeasTableItem $row
  * @param boolean            $isNew
  *
  * @return null|boolean
  */
 public function onCommentAfterSave($context, $row, $isNew)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     if ($app->isAdmin()) {
         return null;
     }
     if (strcmp("com_userideas.comment", $context) != 0) {
         return null;
     }
     $emailId = $this->params->get("post_comment_email_id", 0);
     // Check for enabled option for sending mail
     // when user sends a comment.
     if (!empty($emailId)) {
         if ($isNew and !empty($row->id)) {
             jimport("userideas.item");
             $item = new UserIdeasItem(JFactory::getDbo());
             $item->load($row->get("item_id"));
             $success = $this->sendMail($emailId, $item->getTitle(), $item->getSlug(), $item->getCategorySlug());
             if (!$success) {
                 return false;
             }
         }
     }
     return true;
 }
コード例 #2
0
 /**
  * This method is executed when someone sends a comment.
  *
  * @param string             $context
  * @param UserIdeasTableItem $row
  * @param boolean            $isNew
  *
  * @return null|boolean
  */
 public function onCommentAfterSave($context, $row, $isNew)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     if ($app->isAdmin()) {
         return null;
     }
     if (strcmp('com_userideas.comment', $context) !== 0) {
         return null;
     }
     $emailId = (int) $this->params->get('post_comment_email_id', 0);
     // Check for enabled option for sending mail
     // when user sends a comment.
     if ($emailId > 0 and ($isNew and $row->id > 0)) {
         $item = new Userideas\Item\Item(JFactory::getDbo());
         $item->load($row->get('item_id'));
         $success = $this->sendMail($emailId, $item->getTitle(), $item->getSlug(), $item->getCategorySlug());
         if (!$success) {
             return false;
         }
     }
     return true;
 }
コード例 #3
0
ファイル: item.php プロジェクト: bellodox/UserIdeas
 /**
  * A protected method to get a set of ordering conditions.
  *
  * @param    UserIdeasTableItem $table
  *
  * @return    array    An array of conditions to add to add to ordering queries.
  * @since    1.6
  */
 protected function getReorderConditions($table)
 {
     $condition = array();
     $condition[] = 'catid = ' . (int) $table->get('catid');
     return $condition;
 }
コード例 #4
0
ファイル: form.php プロジェクト: bellodox/UserIdeas
 /**
  * Prepare and sanitise the table prior to saving.
  *
  * @param UserIdeasTableItem $table
  * @since    1.6
  */
 protected function prepareTable(&$table)
 {
     // get maximum order number
     if (!$table->get('id')) {
         // Set ordering to the last item if not set
         if (empty($table->ordering)) {
             $db = $this->getDbo();
             $query = $db->getQuery(true);
             $query->select('MAX(a.ordering)')->from($db->quoteName('#__uideas_items', 'a'));
             $db->setQuery($query, 0, 1);
             $max = $db->loadResult();
             $table->set('ordering', $max + 1);
         }
     }
     // Fix magic quotes
     if (get_magic_quotes_gpc()) {
         $table->set('alias', stripcslashes($table->title));
         $table->set('description', stripcslashes($table->description));
     }
     // If does not exist alias, I will generate the new one from the title
     if (!$table->get('alias')) {
         $table->set('alias', $table->get('title'));
     }
     $table->set('alias', JApplicationHelper::stringURLSafe($table->get('alias')));
 }