delete() public method

Delete the row from the database.
public delete ( ) : boolean
return boolean TRUE if the record was deleted, false if not.
Example #1
0
    /**
     * @return boolean
     */
    public function delete()
    {
        if (!$this->exists()) {
            return false;
        }

        // Unlink articles
        ArticleAuthor::OnAuthorDelete($this->getId());
        // Unlink aliases
        AuthorAlias::OnAuthorDelete($this->getId());
        // Unlink authors
        AuthorAssignedType::OnAuthorDelete($this->getId());
        // Unlink biographies
        AuthorBiography::OnAuthorDelete($this->getId());

        // Save author data for logging purposes
        $tmpData = $this->m_data;
        // Delete row from Authors table.
        $result = parent::delete();
        if ($result) {
            if (function_exists("camp_load_translation_strings")) {
                camp_load_translation_strings("api");
            }
            $logText = getGS('Author #$1 "$2" deleted.',
                $tmpData['id'], $tmpData['first_name'] . ' ' . $tmpData['last_name']);
            Log::Message($logText, null, 174);
        }

        return $result;
    }
Example #2
0
 public function delete()
 {
     $deleted = parent::delete();
     $CampCache = CampCache::singleton();
     $CampCache->clear('user');
     return $deleted;
 }
Example #3
0
    public function delete()
    {
        if (!$this->exists()) {
            return false;
        }
        // Deleting the from from disk path is the most common place for
        // something to go wrong, so we do that first.
        $file = $this->getStorageLocation();
        if (file_exists($file) && is_file($file)) {
            unlink($file);
        }

        // Delete all the references to this image.
        ArticleAttachment::OnAttachmentDelete($this->m_data['id']);

        // Delete the description
        Translation::deletePhrase($this->m_data['fk_description_id']);

        $tmpData = $this->m_data;

        // Delete the record in the database
        $success = parent::delete();

        $logtext = getGS('File #$1 "$2" deleted.', $tmpData['id'], $tmpData['file_name']);
        Log::Message($logtext, null, 39);
        return $success;
    } // fn delete
Example #4
0
 /**
  * Delete this subscription and all cooresponding section subscriptions.
  *
  * @return boolean
  */
 public function delete()
 {
     global $g_ado_db;
     $queryStr = "DELETE FROM SubsSections WHERE IdSubscription=" . $this->m_data['Id'];
     $g_ado_db->Execute($queryStr);
     $deleted = parent::delete();
     return $deleted;
 }
Example #5
0
 public function delete()
 {
     if (!$this->exists()) {
         return false;
     }
     // Delete the description
     Translation::deletePhrase($this->m_data['fk_description_id']);
     // Delete the record in the database
     return parent::delete();
 }
Example #6
0
 public function delete()
 {
     $database = $this->getDatabase();
     $database->transaction();
     try {
         $this->data->clearAll();
         parent::delete();
     } catch (Exception $e) {
         $database->rollback();
     }
     $database->commit();
 }
Example #7
0
 /**
  * Delete the language, this will also delete the language files unless
  * the parameter specifies otherwise.
  *
  * @return boolean
  */
 public function delete($p_deleteLanguageFiles = true)
 {
     if (is_link($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php')) {
         unlink($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php');
     }
     $tmpData = $this->m_data;
     $success = parent::delete();
     if ($success) {
         CampCache::singleton()->clear('user');
     }
     return $success;
 }
Example #8
0
 /**
  * Delete the publication and all of its aliases.
  *
  * @return boolean
  */
 public function delete()
 {
     $aliases = Alias::GetAliases(null, $this->m_data['Id']);
     if ($aliases && count($aliases) > 0) {
         foreach ($aliases as $alias) {
             $alias->delete();
         }
     }
     $tmpData = $this->m_data;
     $deleted = parent::delete();
     return $deleted;
 }
Example #9
0
	public function delete()
	{
	        $tmpData = $this->m_data;
		$success = parent::delete();
		if ($success) {
			if (function_exists("camp_load_translation_strings")) {
				camp_load_translation_strings("api");
			}
			$logtext = getGS('Country "$1" ($2) deleted', $tmpData['Name'], $tmpData['Code']);
			Log::Message($logtext, null, 134);
		}
		return $success;
	} // fn delete
Example #10
0
 /**
  * @return boolean
  */
 public function delete()
 {
     if (!$this->exists()) {
         return false;
     }
     // Unlink articles
     ArticleAuthor::OnAuthorTypeDelete($this->getId());
     // Unlink authors
     AuthorAssignedType::OnAuthorTypeDelete($this->getId());
     // Delete this author type
     $authorType = $this->getName();
     $result = parent::delete();
     return $result;
 }
Example #11
0
	public function delete()
	{
	    $articleNumber = $this->getArticleNumber();
	    $deleted = parent::delete();
	    if ($deleted) {
	        if (function_exists("camp_load_translation_strings")) {
		    camp_load_translation_strings("api");
		}
		$logtext = getGS('Scheduled action deleted from Article #$1',
				 $articleNumber);
		Log::Message($logtext, null, 37);
	    }
	    return $deleted;
	} // fn delete
 public static function setObjectStatusAction(DatabaseObject &$object, $action)
 {
     if ($action == 'publish') {
         $object->sendLive();
         $object->save();
     } else {
         if ($action == 'unpublish') {
             $object->sendBackToDraft();
             //echo "object sent back to draft";
             $object->save();
         } else {
             if ($action == 'delete') {
                 $object->delete();
             }
         }
     }
 }
Example #13
0
 /**
  * @return boolean
  */
 public function delete()
 {
     if (!$this->exists()) {
         return false;
     }
     // Unlink articles
     ArticleAuthor::OnAuthorDelete($this->getId());
     // Unlink aliases
     AuthorAlias::OnAuthorDelete($this->getId());
     // Unlink authors
     AuthorAssignedType::OnAuthorDelete($this->getId());
     // Unlink biographies
     AuthorBiography::OnAuthorDelete($this->getId());
     // Save author data for logging purposes
     $tmpData = $this->m_data;
     // Delete row from Authors table.
     $result = parent::delete();
     return $result;
 }
Example #14
0
 /**
  * Delete record from database.
  *
  * @return boolean
  */
 function delete()
 {
     // Delete record from the database
     $deleted = parent::delete();
     /*
     if ($deleted) {
         if (function_exists("camp_load_translation_strings")) {
             camp_load_translation_strings("api");
         }
         $logtext = getGS('Article #$1: "$2" ($3) deleted.',
             $this->m_data['Number'], $this->m_data['Name'],    $this->getLanguageName())
             ." (".getGS("Publication")." ".$this->m_data['IdPublication'].", "
             ." ".getGS("Issue")." ".$this->m_data['NrIssue'].", "
             ." ".getGS("Section")." ".$this->m_data['NrSection'].")";
         Log::Message($logtext, null, 32);
     }
     */
     $CampCache = CampCache::singleton();
     $CampCache->clear('user');
     return $deleted;
 }
Example #15
0
 /**
  * Delete the Issue, and optionally all sections and articles contained within it.
  * @param boolean $p_deleteSections
  * @param boolean $p_deleteArticles
  * @return int
  * 		Return the number of articles deleted.
  */
 public function delete($p_deleteSections = true, $p_deleteArticles = true)
 {
     global $g_ado_db;
     // Delete all scheduled publishing events
     IssuePublish::OnIssueDelete($this->m_data['IdPublication'], $this->m_data['Number'], $this->m_data['IdLanguage']);
     $articlesDeleted = 0;
     if ($p_deleteSections) {
         $sections = Section::GetSections($this->m_data['IdPublication'], $this->m_data['Number'], $this->m_data['IdLanguage']);
         foreach ($sections as $section) {
             $articlesDeleted += $section->delete($p_deleteArticles);
         }
     }
     $tmpData = $this->m_data;
     $success = parent::delete();
     if ($success) {
         $outputSettingIssues = $this->getOutputSettingIssueService()->findByIssue($tmpData['id']);
         foreach ($outputSettingIssues as $outputSet) {
             $this->getOutputSettingIssueService()->delete($outputSet);
         }
     }
     return $articlesDeleted;
 }
Example #16
0
 /**
  * Deletes the current article type field.
  */
 public function delete()
 {
     global $g_ado_db;
     if (!$this->exists()) {
         return false;
     }
     $oldFieldName = $this->m_data['field_name'];
     $typeName = $this->m_data['type_name'];
     $typeType = $this->getType();
     $orders = $this->getOrders();
     $translation = new Translation(null, $this->getPhraseId());
     $translation->deletePhrase();
     $success = false;
     if ($this->getPrintName() != 'NULL') {
         $queryStr = "ALTER TABLE `X" . $this->m_data['type_name'] . "` DROP COLUMN `" . $this->getName() . "`";
         $success = $g_ado_db->Execute($queryStr);
     }
     if ($success || $this->getPrintName() == 'NULL') {
         $myType = $this->getType();
         if ($myType == self::TYPE_TOPIC) {
             $queryStr = "DELETE FROM TopicFields WHERE ArticleType = " . $g_ado_db->escape($this->m_data['type_name']) . " and FieldName = " . $g_ado_db->escape($this->m_data['field_name']);
             $g_ado_db->Execute($queryStr);
             $this->m_rootTopicId = null;
         }
         $fieldName = $this->m_data['field_name'];
         $success = parent::delete();
     }
     if ($success) {
         if ($typeType == self::TYPE_COMPLEX_DATE) {
             $em = Zend_Registry::get('container')->getService('em');
             $repo = $em->getRepository('Newscoop\\Entity\\ArticleDatetime');
             $repo->deleteField($typeName, array('old' => $oldFieldName));
         }
     }
     // reorder
     if ($success) {
         $newOrders = array();
         foreach ($orders as $k => $v) {
             if (array_key_exists('field_name', $this->m_data)) {
                 if ($v != $this->m_data['field_name']) {
                     $newOrders[] = $v;
                 }
             }
         }
         $newOrders = array_reverse($newOrders);
         $this->setOrders($newOrders);
         CampCache::singleton()->clear('user');
     }
     return $success;
 }
Example #17
0
 /**
  * Delete the language, this will also delete the language files unless
  * the parameter specifies otherwise.
  *
  * @return boolean
  */
 public function delete($p_deleteLanguageFiles = true)
 {
     if (is_link($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php')) {
         unlink($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php');
     }
     if ($p_deleteLanguageFiles) {
         $result = Localizer::DeleteLanguageFiles($this->getCode());
         if (PEAR::isError($result)) {
             return result;
         }
     }
     $tmpData = $this->m_data;
     $success = parent::delete();
     if ($success) {
         CampCache::singleton()->clear('user');
     }
     return $success;
 }
Example #18
0
 public function delete()
 {
     $this->deleteLicenseConsortiums();
     parent::delete();
 }
 /**
  * Delete record from database.
  *
  * @return boolean
  */
 function delete()
 {
     // delete correspondending Attachment object if not used by other DebateAnswers
     $DebateAnswerAttachments = DebateAnswerAttachment::getDebateAnswerAttachments(null, null, $this->getProperty('fk_attachment_id'));
     if (count($DebateAnswerAttachments) === 1) {
         $DebateAnswerAttachment = current($DebateAnswerAttachments);
         $DebateAnswerAttachment->getAttachment()->delete();
     }
     // Delete record from the database
     $deleted = parent::delete();
     /*
     if ($deleted) {
         if (function_exists("camp_load_translation_strings")) {
             camp_load_translation_strings("api");
         }
         $logtext = getGS('Article #$1: "$2" ($3) deleted.',
             $this->m_data['Number'], $this->m_data['Name'],    $this->getLanguageName())
             ." (".getGS("Publication")." ".$this->m_data['IdPublication'].", "
             ." ".getGS("Issue")." ".$this->m_data['NrIssue'].", "
             ." ".getGS("Section")." ".$this->m_data['NrSection'].")";
         Log::Message($logtext, null, 32);
     }
     */
     $CampCache = CampCache::singleton();
     $CampCache->clear('user');
     return $deleted;
 }
Example #20
0
 /**
  * Remove the linkage between the given image and the given article and remove
  * the image tags from the article text.
  *
  * @return boolean
  */
 public function delete()
 {
     if (!$this->exists()) {
         return false;
     }
     $p_imageId = $this->m_data['IdImage'];
     $p_articleNumber = $this->m_data['Number'];
     ArticleImage::RemoveImageTagsFromArticleText($this->getArticleNumber(), $this->getTemplateId());
     $image_id = $this->getImageId();
     $article_number = $this->getArticleNumber();
     $result = parent::delete();
     $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
     $cacheService->clearNamespace('article_image');
     return $result;
 }
Example #21
0
	/**
	 * Delete the row from the database, all article references to this image,
	 * and the file(s) on disk.
	 *
	 * @return mixed
	 *		TRUE if the record was deleted,
	 * 		return a PEAR_Error on failure.
	 */
	public function delete()
	{
		require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleImage.php');

		if (function_exists("camp_load_translation_strings")) {
			camp_load_translation_strings("api");
		}

		// Deleting the images from disk is the most common place for
		// something to go wrong, so we do that first.
		$thumb = $this->getThumbnailStorageLocation();
		$imageFile = $this->getImageStorageLocation();

		if (file_exists($thumb) && !is_writable($thumb)) {
			return new PEAR_Error(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $thumb), CAMP_ERROR_DELETE_FILE);
		}
		if (file_exists($imageFile) && !is_writable($imageFile)) {
			return new PEAR_Error(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $imageFile), CAMP_ERROR_DELETE_FILE);
		}
		if (file_exists($imageFile) && !unlink($imageFile)) {
			return new PEAR_Error(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $imageFile), CAMP_ERROR_DELETE_FILE);
		}
		if (file_exists($thumb) && !unlink($thumb)) {
			return new PEAR_Error(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $thumb), CAMP_ERROR_DELETE_FILE);
		}

		// Delete all the references to this image.
		ArticleImage::OnImageDelete($this->getImageId());

		$imageId = $this->getImageId();
		$imageDescription = $this->getDescription();
		// Delete the record in the database
		if (!parent::delete()) {
			return new PEAR_Error(getGS("Could not delete record from the database."));
		}

		$logtext = getGS('Image "$1" ($2) deleted', $imageDescription, $imageId);
		Log::Message($logtext, null, 42);
		return true;
	} // fn delete
Example #22
0
 /**
  * Delete poll from database.  This will
  * only delete one specific translation of the poll.
  *
  * @return boolean
  */
 public function delete()
 {
     // Delete from plugin_poll_answer table
     PollAnswer::OnPollDelete($this->m_data['poll_nr'], $this->m_data['fk_language_id']);
     // Delete from plugin_poll_article table
     // Delete from plugin_poll_section table
     // Delete from plugin_poll_issue table
     // Delete from plugin_poll_publication table
     // Delete from plugin_poll_main table
     // note: first set votes to null, to recalculate statistics
     $this->setProperty('nr_of_votes', 0);
     $this->setProperty('nr_of_votes_overall', 0);
     $this->triggerStatistics();
     // finally delete the poll
     $deleted = parent::delete();
     /*
     if ($deleted) {
         if (function_exists("camp_load_translation_strings")) {
             camp_load_translation_strings("api");
         }
         $logtext = getGS('Article #$1: "$2" ($3) deleted.',
             $this->m_data['Number'], $this->m_data['Name'],    $this->getLanguageName())
             ." (".getGS("Publication")." ".$this->m_data['IdPublication'].", "
             ." ".getGS("Issue")." ".$this->m_data['NrIssue'].", "
             ." ".getGS("Section")." ".$this->m_data['NrSection'].")";
         Log::Message($logtext, null, 32);
     }
     */
     $CampCache = CampCache::singleton();
     $CampCache->clear('user');
     return $deleted;
 }
Example #23
0
	public function delete()
	{
		$startIPstring = $this->getStartIPstring();
		$addresses = $this->getAddresses();
		$result = parent::delete();
		if ($result) {
			$logtext = getGS('The IP address group $1 has been deleted.', "$startIPstring:$addresses");
			Log::Message($logtext, null, 58);
		}
		return $result;
	}
Example #24
0
    /**
     * Delete article from database.  This will
     * only delete one specific translation of the article.
     *
     * @return boolean
     */
    public function delete()
    {
        // It is an optimization to put these here because in most cases
        // you dont need these files.
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleImage.php');
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleTopic.php');
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleIndex.php');
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleAttachment.php');
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleComment.php');
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticlePublish.php');

        // Delete scheduled publishing
        ArticlePublish::OnArticleDelete($this->m_data['Number'], $this->m_data['IdLanguage']);

        // Delete Article Comments
        ArticleComment::OnArticleDelete($this->m_data['Number'], $this->m_data['IdLanguage']);

        // is this the last translation?
        if (count($this->getLanguages()) <= 1) {
            // Delete image pointers
            ArticleImage::OnArticleDelete($this->m_data['Number']);

            // Delete topics pointers
            ArticleTopic::OnArticleDelete($this->m_data['Number']);

            // Delete file pointers
            ArticleAttachment::OnArticleDelete($this->m_data['Number']);

            // Delete indexes
            ArticleIndex::OnArticleDelete($this->getPublicationId(), $this->getIssueNumber(),
                $this->getSectionNumber(), $this->getLanguageId(), $this->getArticleNumber());
        }

        // geo-map processing
        // is this the last translation?
        if (count($this->getLanguages()) <= 1) {
            // unlink the article-map pointers
            Geo_Map::OnArticleDelete($this->m_data['Number']);
        }
        else {
            // removing non-last translation of the map poi contents
            Geo_Map::OnLanguageDelete($this->m_data['Number'], $this->m_data['IdLanguage']);
        }

        // Delete row from article type table.
        $articleData = new ArticleData($this->m_data['Type'],
            $this->m_data['Number'],
            $this->m_data['IdLanguage']);
        $articleData->delete();

        $tmpObj = clone $this; // for log
        $tmpData = $this->m_data;
        $tmpData['languageName'] = $this->getLanguageName();
        // Delete row from Articles table.
        $deleted = parent::delete();

        if ($deleted) {
            if (function_exists("camp_load_translation_strings")) {
                camp_load_translation_strings("api");
            }
            Log::ArticleMessage($tmpObj, getGS('Article deleted.'), null, 32);
        }
        $this->m_cacheUpdate = true;
        return $deleted;
    } // fn delete
Example #25
0
	/**
	 * Delete the Issue, and optionally all sections and articles contained within it.
	 * @param boolean $p_deleteSections
	 * @param boolean $p_deleteArticles
	 * @return int
	 * 		Return the number of articles deleted.
	 */
	public function delete($p_deleteSections = true, $p_deleteArticles = true)
	{
	    global $g_ado_db;

	    // Delete all scheduled publishing events
	    IssuePublish::OnIssueDelete($this->m_data['IdPublication'], $this->m_data['Number'], $this->m_data['IdLanguage']);

	    $articlesDeleted = 0;
	    if ($p_deleteSections) {
	        $sections = Section::GetSections($this->m_data['IdPublication'], $this->m_data['Number'], $this->m_data['IdLanguage']);
    		foreach ($sections as $section) {
		    $articlesDeleted += $section->delete($p_deleteArticles);
    		}
	    }

	    $tmpData = $this->m_data;
	    $success = parent::delete();
	    if ($success) {
	        if (function_exists("camp_load_translation_strings")) {
		    camp_load_translation_strings("api");
		}
	    	$logtext = getGS('Issue "$1" ($2) from publication $3 deleted',
				 $tmpData['Name'], $tmpData['Number'],
				 $tmpData['IdPublication']);
		Log::Message($logtext, null, 12);
	    }
	    return $articlesDeleted;
	} // fn delete
Example #26
0
 /**
  * Delete article from database.  This will
  * only delete one specific translation of the article.
  *
  * @return boolean
  */
 public function delete()
 {
     // It is an optimization to put these here because in most cases
     // you dont need these files.
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleImage.php';
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleTopic.php';
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleIndex.php';
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleAttachment.php';
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticlePublish.php';
     // Delete scheduled publishing
     ArticlePublish::OnArticleDelete($this->m_data['Number'], $this->m_data['IdLanguage']);
     $translator = \Zend_Registry::get('container')->getService('translator');
     // Delete Article Comments
     // @todo change this with DOCTRINE2 CASCADE DELETE
     $em = Zend_Registry::get('container')->getService('em');
     $repository = $em->getRepository('Newscoop\\Entity\\Comment');
     $repository->deleteArticle($this->m_data['Number'], $this->m_data['IdLanguage']);
     $repository = $em->getRepository('Newscoop\\Entity\\ArticleDatetime');
     $repository->deleteByArticle($this->m_data['Number']);
     $em->flush();
     // is this the last translation?
     if (count($this->getLanguages()) <= 1) {
         // Delete image pointers
         ArticleImage::OnArticleDelete($this->m_data['Number']);
         // Delete topics pointers
         ArticleTopic::OnArticleDelete($this->m_data['Number']);
         // Delete file pointers
         ArticleAttachment::OnArticleDelete($this->m_data['Number']);
         // Delete related articles
         ContextBox::OnArticleDelete($this->m_data['Number']);
         ContextBoxArticle::OnArticleDelete($this->m_data['Number']);
         // Delete the article from playlists
         $em = Zend_Registry::get('container')->getService('em');
         $repository = $em->getRepository('Newscoop\\Entity\\PlaylistArticle');
         $repository->deleteArticle($this->m_data['Number']);
         $em->flush();
         // Delete indexes
         ArticleIndex::OnArticleDelete($this->getPublicationId(), $this->getIssueNumber(), $this->getSectionNumber(), $this->getLanguageId(), $this->getArticleNumber());
     }
     // geo-map processing
     // is this the last translation?
     if (count($this->getLanguages()) <= 1) {
         // unlink the article-map pointers
         Geo_Map::OnArticleDelete($this->m_data['Number']);
     } else {
         // removing non-last translation of the map poi contents
         Geo_Map::OnLanguageDelete($this->m_data['Number'], $this->m_data['IdLanguage']);
     }
     // Delete row from article type table.
     $articleData = new ArticleData($this->m_data['Type'], $this->m_data['Number'], $this->m_data['IdLanguage']);
     $articleData->delete();
     $tmpObj = clone $this;
     // for log
     $tmpData = $this->m_data;
     $tmpData['languageName'] = $this->getLanguageName();
     // Delete row from Articles table.
     $deleted = parent::delete();
     if ($deleted) {
         $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
         $cacheService->clearNamespace('article');
         Log::ArticleMessage($tmpObj, $translator->trans('Article deleted.', array(), 'api'), null, 32);
     }
     $this->m_cacheUpdate = true;
     return $deleted;
 }
Example #27
0
 /**
  * Delete the row from the database, all article references to this image,
  * and the file(s) on disk.
  *
  * @return mixed
  *               TRUE if the record was deleted,
  *               return a PEAR_Error on failure.
  */
 public function delete()
 {
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleImage.php';
     $translator = \Zend_Registry::get('container')->getService('translator');
     $imageStorageService = Zend_Registry::get('container')->getService('image.update_storage');
     if ($imageStorageService->isDeletable($this->getImageFileName())) {
         // Deleting the images from disk is the most common place for
         // something to go wrong, so we do that first.
         $thumb = $this->getThumbnailStorageLocation();
         $imageFile = $this->getImageStorageLocation();
         if (file_exists($thumb) && !is_writable($thumb)) {
             return new PEAR_Error(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $thumb), CAMP_ERROR_DELETE_FILE);
         }
         if (file_exists($imageFile) && !is_writable($imageFile)) {
             return new PEAR_Error(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $imageFile), CAMP_ERROR_DELETE_FILE);
         }
         if (file_exists($imageFile) && !unlink($imageFile)) {
             return new PEAR_Error(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $imageFile), CAMP_ERROR_DELETE_FILE);
         }
         if (file_exists($thumb) && !unlink($thumb)) {
             return new PEAR_Error(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $thumb), CAMP_ERROR_DELETE_FILE);
         }
     }
     // Delete all the references to this image.
     ArticleImage::OnImageDelete($this->getImageId());
     $imageId = $this->getImageId();
     $imageDescription = $this->getDescription();
     // @ticket CS-4225
     $em = \Zend_Registry::get('container')->getService('em');
     $entity = $em->find('Newscoop\\Image\\LocalImage', $imageId);
     $em->remove($entity);
     $em->flush();
     // Delete the record in the database
     if (!parent::delete()) {
         return new PEAR_Error($translator->trans("Could not delete record from the database.", array(), 'api'));
     }
     return true;
 }
Example #28
0
	/**
	 * Delete the language, this will also delete the language files unless
	 * the parameter specifies otherwise.
	 *
	 * @return boolean
	 */
	public function delete($p_deleteLanguageFiles = true)
	{
		if (is_link($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php')) {
			unlink($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php');
		}
		if ($p_deleteLanguageFiles) {
			$result = Localizer::DeleteLanguageFiles($this->getCode());
			if (PEAR::isError($result)) {
				return result;
			}
		}
		$tmpData = $this->m_data;
		$success = parent::delete();
		if ($success) {
		        CampCache::singleton()->clear('user');
			if (function_exists("camp_load_translation_strings")) {
				camp_load_translation_strings("api");
			}
			$logtext = getGS('Language "$1" ($2) deleted', $tmpData['Name'], $tmpData['OrigName']);
			Log::Message($logtext, null, 102);
		}
		return $success;
	} // fn delete
Example #29
0
 /**
  * Remove the linkage between the given image and the given article and remove
  * the image tags from the article text.
  *
  * @return boolean
  */
 public function delete()
 {
     if (!$this->exists()) {
         return false;
     }
     $p_imageId = $this->m_data['IdImage'];
     $p_articleNumber = $this->m_data['Number'];
     ArticleImage::RemoveImageTagsFromArticleText($this->getArticleNumber(), $this->getTemplateId());
     $image_id = $this->getImageId();
     $article_number = $this->getArticleNumber();
     $result = parent::delete();
     return $result;
 }
Example #30
0
    /**
     * Delete interview item from database.
     *
     * @return boolean
     */
    public function delete()
    {
        global $g_ado_db;

        // reduce order of all following items minus 1
        $currItemOrder = $this->getProperty('position');
        $queryStr = "   UPDATE  {$this->m_dbTableName}
                        SET     position = position - 1
                        WHERE   fk_interview_id = {$this->m_data['fk_interview_id']}
                                AND position > $currItemOrder";
        $g_ado_db->Execute($queryStr);

        // finally delete from main table
        $deleted = parent::delete();

        /*
        if ($deleted) {
            if (function_exists("camp_load_translation_strings")) {
                camp_load_translation_strings("api");
            }
            $logtext = getGS('Interview #$1: "$2" ($3) deleted.',
                $this->m_data['Number'], $this->m_data['Name'],    $this->getLanguageName())
                ." (".getGS("Publication")." ".$this->m_data['IdPublication'].", "
                ." ".getGS("Issue")." ".$this->m_data['NrIssue'].", "
                ." ".getGS("Section")." ".$this->m_data['NrSection'].")";
            Log::Message($logtext, null, 32);
        }
        */

        $CampCache = CampCache::singleton();
        $CampCache->clear('user');
        return $deleted;
    } // fn delete