Example #1
0
 public function afterSave(&$translator, $sourceid, &$row)
 {
     //Clone images?
     $clone = (int) $translator->params->get('k2_clone_image', 1);
     if ($clone) {
         $imgpath = JPATH_ROOT . '/media/k2/items/';
         $srcfile = md5('Image' . $sourceid);
         $dstfile = md5('Image' . $row[$this->primarykey]);
         if (JFile::exists($imgpath . 'src/' . $srcfile . '.jpg') && !JFile::exists($imgpath . 'src/' . $dstfile . '.jpg')) {
             JFile::copy($imgpath . 'src/' . $srcfile . '.jpg', $imgpath . 'src/' . $dstfile . '.jpg');
             JFile::copy($imgpath . 'cache/' . $srcfile . '_Generic.jpg', $imgpath . 'cache/' . $dstfile . '_Generic.jpg');
             JFile::copy($imgpath . 'cache/' . $srcfile . '_L.jpg', $imgpath . 'cache/' . $dstfile . '_L.jpg');
             JFile::copy($imgpath . 'cache/' . $srcfile . '_M.jpg', $imgpath . 'cache/' . $dstfile . '_M.jpg');
             JFile::copy($imgpath . 'cache/' . $srcfile . '_S.jpg', $imgpath . 'cache/' . $dstfile . '_S.jpg');
             JFile::copy($imgpath . 'cache/' . $srcfile . '_XL.jpg', $imgpath . 'cache/' . $dstfile . '_XL.jpg');
             JFile::copy($imgpath . 'cache/' . $srcfile . '_XS.jpg', $imgpath . 'cache/' . $dstfile . '_XS.jpg');
         }
     }
     //
     parent::afterSave($translator, $sourceid, $row);
 }
Example #2
0
 public function afterSave(&$translator, $sourceid, &$row)
 {
     //Update menu assignment
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('menuid')->from('#__modules_menu')->where('moduleid=' . $db->quote($sourceid));
     $db->setQuery($query);
     $items = $db->loadObjectList();
     if (count($items)) {
         $targetid = $row[$this->primarykey];
         $query->clear();
         $query->delete('#__modules_menu')->where('moduleid=' . $db->quote($targetid));
         $db->setQuery($query);
         $db->execute();
         foreach ($items as $item) {
             if ($item->menuid == 0) {
                 //all
                 $menuid = 0;
             } elseif ($item->menuid > 0) {
                 //selected menu
                 $menuid = $translator->getAssociatedItem('menu', $item->menuid, $item->menuid);
             } else {
                 //all but exclude selected
                 $oldmenuid = abs($item->menuid);
                 $menuid = -$translator->getAssociatedItem('menu', $oldmenuid, $oldmenuid);
             }
             $query->clear();
             $query->insert('#__modules_menu')->columns('moduleid, menuid');
             $query->values($db->quote($targetid) . ',' . $db->quote($menuid));
             $db->setQuery($query);
             $db->execute();
         }
     }
     //
     parent::afterSave($translator, $sourceid, $row);
 }
 public function afterSave(&$translator, $sourceid, &$row)
 {
     //clone tag
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('tag_id')->from('#__easyblog_post_tag')->where('post_id=' . $db->quote($sourceid));
     $db->setQuery($query);
     $items = $db->loadObjectList();
     if (count($items)) {
         $targetid = $row[$this->primarykey];
         $date = JFactory::getDate()->toSql();
         $query->clear();
         $query->delete('#__easyblog_post_tag')->where('post_id=' . $db->quote($targetid));
         $db->setQuery($query);
         $db->execute();
         foreach ($items as $item) {
             $query->clear();
             $query->insert('#__easyblog_post_tag')->columns('tag_id, post_id, created');
             $query->values($db->quote($item->tag_id) . ',' . $db->quote($targetid) . ',' . $db->quote($date));
             $db->setQuery($query);
             $db->execute();
         }
     }
     //check & update featured entry
     $query->clear();
     $query->select('id')->from('#__easyblog_featured')->where('type="post" AND content_id=' . $db->quote($sourceid));
     $db->setQuery($query);
     $item = $db->loadResult();
     if ($item) {
         $date = JFactory::getDate()->toSql();
         $query->clear();
         $query->insert('#__easyblog_featured')->columns('content_id, type, created');
         $query->values($db->quote($row['id']) . ',"post",' . $db->quote($date));
         $db->setQuery($query);
         $db->execute();
     }
     //
     parent::afterSave($translator, $sourceid, $row);
 }