/** * @return Feed\Object|Feed\Object */ public function post($post = []) { if ($post) { $this->assign($post); } $this->auth(); $this->requires(['type_id', 'content']); // (new \Api\User())->get($this->request->get('user_id')); if (!$this->request->get('content')) { throw error('Add some content.'); } $content = $this->request->get('content'); if (!is_string($content)) { $content = json_encode($content); } $feedId = \Feed_Service_Process::instance()->add(['type_id' => $this->request->get('type_id'), 'content' => $content]); return $this->get($feedId); }
public function updateStatus($aVals) { if (Phpfox::getLib('parse.format')->isEmpty($aVals['user_status'])) { return Phpfox_Error::set(Phpfox::getPhrase('user.add_some_text_to_share')); } if (!Phpfox::getService('ban')->checkAutomaticBan($aVals['user_status'])) { return false; } $sStatus = $this->preParse()->prepare($aVals['user_status']); if (!defined('PHPFOX_INSTALLER')) { $aUpdates = $this->database()->select('content')->from(Phpfox::getT('user_status'))->where('user_id = ' . (int) Phpfox::getUserId())->limit(Phpfox::getParam('user.check_status_updates'))->order('time_stamp DESC')->execute('getSlaveRows'); $iReplications = 0; foreach ($aUpdates as $aUpdate) { if ($aUpdate['content'] == $sStatus) { $iReplications++; } } if ($iReplications > 0) { return Phpfox_Error::set(Phpfox::getPhrase('user.you_have_already_added_this_recently_try_adding_something_else')); } } if (empty($aVals['privacy'])) { $aVals['privacy'] = 0; } if (empty($aVals['privacy_comment'])) { $aVals['privacy_comment'] = 0; } $aInsert = array('user_id' => (int) Phpfox::getUserId(), 'privacy' => $aVals['privacy'], 'privacy_comment' => $aVals['privacy_comment'], 'content' => $sStatus, 'time_stamp' => PHPFOX_TIME); if (isset($aVals['location']) && isset($aVals['location']['latlng']) && !empty($aVals['location']['latlng'])) { $aMatch = explode(',', $aVals['location']['latlng']); $aMatch['latitude'] = floatval($aMatch[0]); $aMatch['longitude'] = floatval($aMatch[1]); $aInsert['location_latlng'] = json_encode(array('latitude' => $aMatch['latitude'], 'longitude' => $aMatch['longitude'])); } if (isset($aInsert['location_latlng']) && !empty($aInsert['location_latlng']) && isset($aVals['location']) && isset($aVals['location']['name']) && !empty($aVals['location']['name'])) { $aInsert['location_name'] = Phpfox::getLib('parse.input')->clean($aVals['location']['name']); } $iStatusId = $this->database()->insert(Phpfox::getT('user_status'), $aInsert); $this->_iStatusId = $iStatusId; if (isset($aVals['privacy']) && $aVals['privacy'] == '4') { Phpfox::getService('privacy.process')->add('user_status', $iStatusId, isset($aVals['privacy_list']) ? $aVals['privacy_list'] : array()); } Phpfox::getService('user.process')->notifyTagged($sStatus, $iStatusId, 'status'); if (Phpfox::isModule('tag') && Phpfox::getParam('tag.enable_hashtag_support')) { Phpfox::getService('tag.process')->add('user_status', $iStatusId, Phpfox::getUserId(), $sStatus, true); } ($sPlugin = Phpfox_Plugin::get('user.service_process_add_updatestatus')) ? eval($sPlugin) : false; $iReturnId = Feed_Service_Process::instance()->add('user_status', $iStatusId, $aVals['privacy'], $aVals['privacy_comment'], 0, null, 0, isset($aVals['parent_feed_id']) ? $aVals['parent_feed_id'] : 0, isset($aVals['parent_module_id']) ? $aVals['parent_module_id'] : null); ($sPlugin = Phpfox_Plugin::get('user.service_process_add_updatestatus_end')) ? eval($sPlugin) : false; return $iReturnId; }