|
|
@@ -893,6 +893,76 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Delete file and story association, also file views, votes, comments, meta data are also deleted
|
|
|
+ * For using in selected modules only
|
|
|
+ * @param $iFileId file ID
|
|
|
+ * @return true on success of false on error
|
|
|
+ */
|
|
|
+ protected function _serviceDeleteFileAssociations($iFileId, $aMediaInfo)
|
|
|
+ {
|
|
|
+ $CNF = &$this->_oConfig->CNF;
|
|
|
+
|
|
|
+ if (!$this->_oDb->deassociateFileWithContent(0, $iFileId))
|
|
|
+ return false;
|
|
|
+
|
|
|
+ $aContentInfo = $this->_oDb->getContentInfoById($aMediaInfo['content_id']);
|
|
|
+ $iSender = isLogged() ? bx_get_logged_profile_id() : $aMediaInfo['author'];
|
|
|
+ $iAuthor = isset($aContentInfo[$CNF['FIELD_AUTHOR']]) ? $aContentInfo[$CNF['FIELD_AUTHOR']] : $aMediaInfo['author'];
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @hooks
|
|
|
+ * @hookdef hook-bx_base_text-media_deleted 'bx_base_text', 'media_deleted' - hook on new media deleted from story
|
|
|
+ * - $unit_name - module name `bx_stories` or `bx_albums`
|
|
|
+ * - $action - equals `media_deleted`
|
|
|
+ * - $object_id - story_id
|
|
|
+ * - $sender_id - author's profile_id
|
|
|
+ * - $extra_params - array of additional params with the following array keys:
|
|
|
+ * - `object_author_id` - [int] confirmation type can be none/phone/email/email_and_phone/email_or_phone
|
|
|
+ * - `subobject_id` - [int] id for added media
|
|
|
+ * - `media_id` - [int] id for added media
|
|
|
+ * - `media_info` - [array] media info
|
|
|
+ * @hook @ref hook-bx_base_text-media_deleted
|
|
|
+ */
|
|
|
+ bx_alert($this->getName(), 'media_deleted', $aMediaInfo['content_id'], $iSender, array(
|
|
|
+ 'object_author_id' => $iAuthor,
|
|
|
+
|
|
|
+ 'subobject_id' => $aMediaInfo['id'],
|
|
|
+
|
|
|
+ 'media_id' => $aMediaInfo['id'],
|
|
|
+ 'media_info' => $aMediaInfo,
|
|
|
+ ));
|
|
|
+
|
|
|
+ bx_alert($this->getName() . '_media', 'deleted', $aMediaInfo['id'], $iSender, array(
|
|
|
+ 'object_id' => $aMediaInfo['content_id'],
|
|
|
+ 'object_author_id' => $iAuthor,
|
|
|
+
|
|
|
+ 'media_info' => $aMediaInfo,
|
|
|
+ ));
|
|
|
+
|
|
|
+ if (!empty($CNF['OBJECT_VIEWS_MEDIA'])) {
|
|
|
+ $o = BxDolView::getObjectInstance($CNF['OBJECT_VIEWS_MEDIA'], $aMediaInfo['id']);
|
|
|
+ if ($o) $o->onObjectDelete();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($CNF['OBJECT_VOTES_MEDIA'])) {
|
|
|
+ $o = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_MEDIA'], $aMediaInfo['id']);
|
|
|
+ if ($o) $o->onObjectDelete();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($CNF['OBJECT_SCORES_MEDIA'])) {
|
|
|
+ $o = BxDolScore::getObjectInstance($CNF['OBJECT_SCORES_MEDIA'], $aMediaInfo['id']);
|
|
|
+ if ($o) $o->onObjectDelete();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($CNF['OBJECT_COMMENTS_MEDIA'])) {
|
|
|
+ $o = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS_MEDIA'], $aMediaInfo['id']);
|
|
|
+ if ($o) $o->onObjectDelete();
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/** @} */
|