public function ajaxAddPhotoTag($photoId, $userId, $posX, $posY, $w, $h) { $filter = JFilterInput::getInstance(); $photoId = $filter->clean($photoId, 'int'); $userId = $filter->clean($userId, 'int'); $posX = $filter->clean($posX, 'float'); $posY = $filter->clean($posY, 'float'); $w = $filter->clean($w, 'float'); $h = $filter->clean($h, 'float'); if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } $response = new JAXResponse(); $json = array(); $my = CFactory::getUser(); $photoModel = CFactory::getModel('photos'); $tagging = new CPhotoTagging(); $tag = new stdClass(); $tag->photoId = $photoId; $tag->userId = $userId; $tag->posX = $posX; $tag->posY = $posY; $tag->width = $w; $tag->height = $h; $tagId = $tagging->addTag($tag); $jsonString = '{}'; if ($tagId > 0) { $user = CFactory::getUser($userId); $isGroup = $photoModel->isGroupPhoto($photoId); $photo = $photoModel->getPhoto($photoId); $json['success'] = true; $json['data'] = array('id' => $tagId, 'userId' => $userId, 'displayName' => $user->getDisplayName(), 'profileUrl' => CRoute::_('index.php?option=com_community&view=profile&userid=' . $userId, false), 'top' => $posX, 'left' => $posY, 'width' => $w, 'height' => $h, 'canRemove' => true); //send notification emails $albumId = $photo->albumid; $photoCreator = $photo->creator; $url = ''; $album = JTable::getInstance('Album', 'CTable'); $album->load($albumId); $handler = $this->_getHandler($album); $url = $photo->getRawPhotoURI(); if ($my->id != $userId) { // Add notification $params = new CParameter(''); $params->set('url', $url); $params->set('photo', JText::_('COM_COMMUNITY_SINGULAR_PHOTO')); $params->set('photo_url', $url); CNotificationLibrary::add('photos_tagging', $my->id, $userId, JText::sprintf('COM_COMMUNITY_SOMEONE_TAG_YOU'), '', 'photos.tagging', $params); } } else { $json['error'] = $tagging->getError(); } die(json_encode($json)); }
public function ajaxAddPhotoTag($photoId, $userId, $posX, $posY, $w, $h) { if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } $response = new JAXResponse(); CFactory::load('libraries', 'phototagging'); CFactory::load('models', 'photos'); $my = CFactory::getUser(); $photoModel = CFactory::getModel('photos'); $tagging = new CPhotoTagging(); $tag = new stdClass(); $tag->photoId = $photoId; $tag->userId = $userId; $tag->posX = $posX; $tag->posY = $posY; $tag->width = $w; $tag->height = $h; $tagId = $tagging->addTag($tag); $jsonString = '{}'; if ($tagId > 0) { $user = CFactory::getUser($userId); $isGroup = $photoModel->isGroupPhoto($photoId); $photo = $photoModel->getPhoto($photoId); $jsonString = '{' . 'id:' . $tagId . ',' . 'photoId:' . $photoId . ',' . 'userId:' . $userId . ',' . 'displayName:\'' . $user->getDisplayName() . '\',' . 'profileUrl:\'' . CRoute::_('index.php?option=com_community&view=profile&userid=' . $userId, false) . '\',' . 'top:' . $posX . ',' . 'left:' . $posY . ',' . 'width:' . $w . ',' . 'height:' . $h . ',' . 'canRemove:true' . '}'; // jQuery call to update photo tagged list. $response->addScriptCall('joms.gallery.createPhotoTag', $jsonString); $response->addScriptCall('joms.gallery.createPhotoTextTag', $jsonString); $response->addScriptCall('cWindowHide'); $response->addScriptCall('joms.gallery.cancelNewPhotoTag'); //send notification emails $albumId = $photo->albumid; $photoCreator = $photo->creator; $url = ''; $album =& JTable::getInstance('Album', 'CTable'); $album->load($albumId); $handler = $this->_getHandler($album); $url = $handler->getPhotoURI($album->id, $photoId, false); if ($my->id != $userId) { // Add notification CFactory::load('libraries', 'notification'); $params = new JParameter(''); $params->set('url', $url); CNotificationLibrary::add('photos.tagging', $my->id, $userId, JText::sprintf('CC SOMEONE TAG YOU', $my->getDisplayName()), '', 'photos.tagging', $params); } } else { $html = $tagging->getError(); $action = '<button class="button" onclick="cWindowHide();joms.gallery.cancelNewPhotoTag();" name="close">' . JText::_('CC BUTTON CLOSE') . '</button>'; //remove the existing cwindow (for friend selection) $response->addScriptCall('joms.jQuery(\'#cWindow\').remove();'); //recreate the warning cwindow $response->addScriptCall('cWindowShow', '', 'Notice', 450, 200, 'warning'); $response->addAssign('cWindowContent', 'innerHTML', $html); $response->addScriptCall('cWindowActions', $action); } return $response->sendResponse(); }