Example #1
0
 function _plgListingAfterSave(&$model)
 {
     // Limit running this for new/edited listings. Not deletion of images or other listing actions.
     if ($this->c->name == 'listings' && in_array($this->c->action, array('_save'))) {
         $listing_id = $model->data['Listing']['id'];
         $listing_title = $model->data['Listing']['title'];
         $relate_id = JRequest::getString('relate_id');
         if (!$relate_id) {
             return;
         }
         // associate new listing with related listing_id
         include_once JPATH_BASE . DS . 'components' . DS . 'com_relate' . DS . 'models' . DS . 'relate.php';
         $model = new RelateModelRelate();
         $rids = explode(',', $relate_id);
         $rel_titles = array();
         foreach ($rids as $rel_id) {
             if (!is_numeric($rel_id)) {
                 continue;
             }
             $result = $model->add_listings($rel_id, array($listing_id));
             if ($result > 1) {
                 // get title of related listing
                 $db =& JFactory::getDBO();
                 $sql = "SELECT title FROM #__content WHERE id = '{$rel_id}'";
                 $db->setQuery($sql);
                 $rel_titles[] = $db->loadResult();
             }
         }
         if (count($rel_titles)) {
             $relate_title = implode(',', $rel_titles);
             echo '<script type="text/javascript">alert("Related ' . $relate_title . ' to ' . $listing_title . '");</script>';
         }
     }
 }
Example #2
0
 public function saveRelation($id1, $id2, $creator, $add_stream)
 {
     include_once JPATH_BASE . DS . 'components' . DS . 'com_relate' . DS . 'models' . DS . 'relate.php';
     $model = new RelateModelRelate();
     // add_listings takes an array of ids to relate to id1
     if (!is_array($id2)) {
         $id2 = array($id2);
     }
     $model->add_listings($id1, $id2, $add_stream, $creator);
 }
Example #3
0
 function _onJomsCreate($item, $type, $relate_id)
 {
     include_once JPATH_BASE . DS . 'components' . DS . 'com_relate' . DS . 'models' . DS . 'relate.php';
     $model = new RelateModelRelate();
     $result = $model->_add_jomsocial($type, $relate_id, array($item->id));
 }