Пример #1
0
 public function removeOnePhotoActivity($app, $uniqueId, $datetime, $photoId, $thumbnail)
 {
     $db = JFactory::getDBO();
     $query = 'SELECT * FROM ' . $db->quoteName('#__community_activities') . ' ' . 'WHERE ' . $db->quoteName('app') . '=' . $db->Quote($app) . ' ' . 'AND ' . $db->quoteName('cid') . '=' . $db->Quote($uniqueId) . ' ' . 'AND ( ' . $db->quoteName('created') . ' BETWEEN ' . $db->Quote($datetime) . ' ' . 'AND ( ADDTIME(' . $db->Quote($datetime) . ', ' . $db->Quote('00:00:05') . ' ) ) ) ';
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     $activityId = null;
     $handler = new CParameter(null);
     // the activity data contains photoid and the photo thumbnail
     // which can be useful for us to find the correct activity id
     foreach ($result as $activity) {
         $handler->loadINI($activity->params);
         if ($handler->getValue('photoid') == $photoId) {
             $activityId = $activity->id;
             break;
         }
         if (JString::strpos($activity->content, $thumbnail) !== false) {
             $activityId = $activity->id;
             break;
         }
     }
     if (is_null($activityId)) {
         return $this->removeOneActivity($app, $uniqueId);
     }
     $query = 'DELETE FROM ' . $db->quoteName('#__community_activities') . ' ' . 'WHERE ' . $db->quoteName('id') . '=' . $db->Quote($activityId) . ' ' . 'LIMIT 1 ';
     $db->setQuery($query);
     $status = $db->query();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     return $status;
 }