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
/** * @param array $p_values * @return boolean */ public function create($p_values = null) { $success = parent::create($p_values); $publicationObj = new Publication($this->m_data['IdPublication']); if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('The default subscription time for ($1 "$2":$3) has been added.', getGS("Publication"), $publicationObj->getName(), $this->m_data['CountryCode']); Log::Message($logtext, null, 4); return $success; } // fn create
/** * Unlink a topic from an article. * @param int $p_topicId * @param int $p_articleNumber * @return void */ public static function RemoveTopicFromArticle($p_topicId, $p_articleNumber) { global $g_ado_db; $queryStr = "DELETE FROM ArticleTopics WHERE NrArticle=$p_articleNumber AND TopicId=$p_topicId"; $g_ado_db->Execute($queryStr); if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Article topic $1 deleted from article $2', $p_topicId, $p_articleNumber); Log::Message($logtext, null, 145); } // fn RemoveTopicFromArticle
/** * @param int $p_authorId * @param int $p_authorTypeId * @return void */ public static function AddAuthorTypeToAuthor($p_authorId, $p_authorTypeId) { global $g_ado_db; $queryStr = 'INSERT IGNORE INTO ' . self::TABLE . ' (fk_author_id, fk_type_id) VALUES (' . (int) $p_authorId . ', ' . (int) $p_authorTypeId . ')'; $g_ado_db->Execute($queryStr); if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logText = getGS('Author type $1 linked to author $2', $p_authorTypeId, $p_authorId); Log::Message($logText, null, 175); }
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
/** * Moves a template from current folder to destination folder. * It does not take care on database info upgrade because * it trusts of the cool Template::UpdateStatus() function. * * @param string $p_current_folder * @param string $p_destination_folder * @return bool true on succes or false on failure */ public function move($p_current_folder, $p_destination_folder) { global $Campsite; global $g_user; if (self::IsValidPath($p_current_folder) && self::IsValidPath($p_destination_folder)) { $currentFolder = ($p_current_folder == '/') ? '' : $p_current_folder; $destinationFolder = ($p_destination_folder == '/') ? '' : $p_destination_folder; $currentFullPath = $Campsite['TEMPLATE_DIRECTORY'] . $currentFolder . '/' . basename($this->getName()); $destinationFullPath = $Campsite['TEMPLATE_DIRECTORY'] . $destinationFolder . '/' . basename($this->getName()); if (rename($currentFullPath, $destinationFullPath)) { $logtext = getGS('Template $1 was moved to $2', mysql_real_escape_string($currentFolder . '/' . basename($this->getName())), mysql_real_escape_string($destinationFolder . '/' . basename($this->getName()))); Log::Message($logtext, $g_user->getUserId(), 117); return true; } } return false; } // fn move
/** * 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
/** * Set the name of the country. * @param string $p_value * @return boolean */ public function setName($p_value) { $oldValue = $this->m_data['Name']; $success = $this->setProperty('Name', $p_value); if ($success) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Country name $1 changed', $this->m_data['Name']." (".$this->m_data['Code'].")"); Log::Message($logtext, null, 133); } return $success; } // fn setName
$email = Input::Get("f_email"); if (stristr($email, "@") == false) { // || stristr($email, ".")==false) $errors[] = getGS("Email: incorrect format."); } if (!isset($errors)) { $usr = User::FetchUserByEmail($email); if ($usr!=null && is_numeric($usr->getUserId()) && $usr->getUserId()>0) { $usr->setPasswordResetToken(); $token = $usr->getPasswordResetToken(); send_token($email, $token); $sent = true; $logMessage = getGS('Password recovery request for $1', $email); Log::Message($logMessage, NULL, 54); } else { $errors[] = getGS("No user is registered with this email."); } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en"> <head> <script src="<?php echo $Campsite['WEBSITE_URL']; ?>/js/crypt.js" type="text/javascript"></script> <link rel="shortcut icon" href="<?php echo $Campsite['ADMIN_STYLE_URL']; ?>/images/7773658c3ccbf03954b4dacb029b2229.ico" /> <link rel="stylesheet" type="text/css" href="<?php echo $Campsite['ADMIN_STYLE_URL']; ?>/admin_stylesheet_new.css" /> <link rel="stylesheet" type="text/css" href="<?php echo $Campsite['ADMIN_STYLE_URL']; ?>/admin_stylesheet.css" />
/** * Sync campsite and phorum users. */ public function syncPhorumUser() { $phorumUser = Phorum_user::GetByUserName($this->m_data['UName']); if ($phorumUser->setPassword($this->m_data['Password']) && $phorumUser->setEmail($this->m_data['EMail'])) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Base data synchronized to phorum user for "$1" ($2)', $this->m_data['Name'], $this->m_data['UName']); Log::Message($logtext, null, 161); } } // fn syncPhorumUser
/** * Delete the user type. * * @return bool * TRUE on success, FALSE on failure */ public function delete() { global $LiveUserAdmin; $filter = array('group_id' => $this->m_data['group_id']); if ($LiveUserAdmin->perm->removeGroup($filter)) { $this->m_exists = false; if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('User type "$1" deleted', $this->m_data['group_define_name']); Log::Message($logtext, null, 122); return true; } return false; } // fn delete
/** * @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; }
} $subscription = new Subscription(); $created = $subscription->create(array( 'IdUser' => $f_user_id, 'IdPublication' => $f_publication_id, 'Active' => $f_subscription_active, 'Type' => $subsType)); if (!$created) { $errorMsgs[] = getGS('The subscription could not be added.') .' '.getGS("Please check if there isn't another subscription to the same publication."); } else { $logtext = getGS('Subscription added for user #$1 (Publication: $2, Active: $3, Type: $4)', $f_user_id, $f_publication_id, $f_subscription_active, $subsType); Log::Message($logtext, null, 181); } if ($created && ($f_add_sections_now == 'Y')) { $columns = array('StartDate' => $f_subscription_start_date, 'Days' => $f_subscription_days, 'PaidDays' => $paidDays); foreach ($f_language_id as $language_id) { $created = SubscriptionSection::AddSubscriberToPublication( $subscription->getSubscriptionId(), $f_publication_id, $language_id, $columns); if (!$created) { $errorMsgs[] = getGS('The sections could not be added successfully. Some of them were already added !'); break;
if (!$canManage) { $error = getGS("You do not have the right to change user type permissions."); camp_html_display_error($error); exit; } $uTypeId = Input::Get('UType', 'string', ''); if (is_numeric($uTypeId) && $uTypeId > 0) { $userType = new UserType($uTypeId); if ($userType->getName() == '') { camp_html_display_error(getGS('No such user type.')); exit; } } else { camp_html_display_error(getGS('No such user type.')); exit; } $rightsFields = User::GetDefaultConfig(); foreach ($rightsFields as $field=>$value) { $val = Input::Get($field, 'string', 'off'); $userType->setPermission($field, ($val != 'off')); } $logtext = getGS('Permissions changed for user type "$1"', $userType->getName()); Log::Message($logtext, $userType->getName(), 123); $msg = getGS("Permissions successfully modified"); camp_html_add_msg($msg, 'ok'); camp_html_goto_page("/$ADMIN/user_types/access.php?UType=$uTypeId"); ?>
/** * @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(); if ($result) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logText = getGS('Article type "$1" deleted.', $authorType); Log::Message($logText, null, 176); } return $result; }
/** * Set the type name for the given language. A new entry in * the database will be created if the language does not exist. * * @param int $p_languageId * @param string $p_value * * @return boolean */ public function setName($p_languageId, $p_value) { global $g_ado_db; if (!is_numeric($p_languageId) || $p_languageId == 0) { return false; } $changed = $this->m_metadata->setName($p_languageId, $p_value); if ($changed) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Article type "$1" translation updated', $this->m_name); Log::Message($logtext, null, 143); } return $changed; } // fn setName
/** * Set the workflow state of the issue. * * @param string $p_value * Can be NULL, 'Y', 'N', TRUE, or FALSE. * If set to NULL, the current value will be reversed. * * @return void */ public function setWorkflowStatus($p_value = null) { $doPublish = null; if (is_null($p_value)) { if ($this->m_data['Published'] == 'Y') { $doPublish = false; } else { $doPublish = true; } } else { if (is_string($p_value)) { $p_value = strtoupper($p_value); } if (($this->m_data['Published'] == 'N') && (($p_value == 'Y') || ($p_value === true))) { $doPublish = true; } elseif (($this->m_data['Published'] == 'Y') && (($p_value == 'N') || ($p_value === false))) { $doPublish = false; } } if (!is_null($doPublish)) { Article::OnIssuePublish($this->getPublicationId(), $this->getLanguageId(), $this->getIssueNumber(), $doPublish); if ($doPublish) { $this->setProperty('Published', 'Y', true); $this->setProperty('PublicationDate', 'NOW()', true, true); } else { $this->setProperty('Published', 'N', true); } // Log message if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } if ($this->getWorkflowStatus() == 'Y') { $status = getGS('Published'); } else { $status = getGS('Not published'); } $logtext = getGS('Issue $1 changed status to $2', $this->m_data['Number'].'. '.$this->m_data['Name'].' ('.$this->getLanguageName().')', $status); Log::Message($logtext, null, 14); } } // fn setWorkflowStatus
/** * Delete the section, and optionally the articles. If you are * deleting the articles, the default is to only delete the articles * with the same language as this section. If you want to delete * all article translations, set the second parameter to TRUE. * * @param boolean $p_deleteArticles * @param boolean $p_deleteArticleTranslations * @return int * Return the number of articles deleted. */ public function delete($p_deleteArticles = false, $p_deleteArticleTranslations = false) { $numArticlesDeleted = 0; if ($p_deleteArticles) { $languageId = null; if (!$p_deleteArticleTranslations) { $languageId = $this->m_data['IdLanguage']; } $articles = Article::GetArticles($this->m_data['IdPublication'], $this->m_data['NrIssue'], $this->m_data['Number'], $languageId); $numArticlesDeleted = count($articles); foreach ($articles as $deleteMe) { $deleteMe->delete(); } } $tmpData = $this->m_data; $success = parent::delete(); if ($success) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Section "$1" ($2) deleted. (Publication: $3, Issue: $4)', $tmpData['Name'], $tmpData['Number'], $tmpData['IdPublication'], $tmpData['NrIssue']); Log::Message($logtext, null, 22); } return $numArticlesDeleted; } // fn delete
/** * Link the given image with the given article. The template ID * is the image's position in the template. * * @param int $p_imageId * @param int $p_articleNumber * @param int $p_templateId * Optional. If not specified, this will be the next highest number * of the existing values. * * @return void */ public static function AddImageToArticle($p_imageId, $p_articleNumber, $p_templateId = null) { global $g_ado_db; if (is_null($p_templateId)) { $p_templateId = ArticleImage::GetUnusedTemplateId($p_articleNumber); } $queryStr = 'INSERT IGNORE INTO ArticleImages(NrArticle, IdImage, Number)' .' VALUES('.$p_articleNumber.', '.$p_imageId.', '.$p_templateId.')'; $g_ado_db->Execute($queryStr); if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Image $1 linked to article $2', $p_imageId, $p_articleNumber); Log::Message($logtext, null, 41); } // fn AddImageToArticle
/** * Set the type name for the given language. A new entry in * the database will be created if the language did not exist. * * @param int $p_languageId * @param string $p_value * * @return boolean */ public function setName($p_languageId, $p_value) { global $g_ado_db; if (!is_numeric($p_languageId)) { return false; } // if the string is empty, nuke it if (!is_string($p_value) || $p_value == '') { if ($phrase_id = $this->translationExists($p_languageId)) { $trans = new Translation($p_languageId, $phrase_id); $trans->delete(); $changed = true; } else { $changed = false; } } else { $description = new Translation($p_languageId, $this->getProperty('fk_phrase_id')); if ($description->exists()) { $changed = $description->setText($p_value); } else { $changed = $description->create($p_value); if ($changed && is_null($this->getProperty('fk_phrase_id'))) { $this->setProperty('fk_phrase_id', $description->getPhraseId()); } } } if ($changed) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Field "$1" updated', $this->m_data['field_name']); Log::Message($logtext, null, 143); } return $changed; } // fn setName
/** * Download the remote file and save it to disk, create a thumbnail for it, * and create a database entry for the file. * * @param string $p_url * The remote location of the file. ("http://..."); * * @param array $p_attributes * Optional attributes which are stored in the database. * Indexes can be the following: 'Description', 'Photographer', 'Place', 'Date' * * @param int $p_userId * The user ID of the user who uploaded the image. * * @param int $p_id * If you are updating an image, specify its ID here. * * @return mixed * Return an Image object on success, return a PEAR_Error otherwise. */ public static function OnAddRemoteImage($p_url, $p_attributes, $p_userId = null, $p_id = null) { global $Campsite; if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } // Check if thumbnail directory is writable. $imageDir = $Campsite['IMAGE_DIRECTORY']; $thumbDir = $Campsite['THUMBNAIL_DIRECTORY']; if (!file_exists($imageDir) || !is_writable($imageDir)) { return new PEAR_Error(camp_get_error_message(CAMP_ERROR_WRITE_DIR, $imageDir), CAMP_ERROR_WRITE_DIR); } if (!file_exists($thumbDir) || !is_writable($thumbDir)) { return new PEAR_Error(camp_get_error_message(CAMP_ERROR_WRITE_DIR, $thumbDir), CAMP_ERROR_WRITE_DIR); } $client = new HTTP_Client(); $client->get($p_url); $response = $client->currentResponse(); if ($response['code'] != 200) { return new PEAR_Error(getGS("Unable to fetch image from remote server.")); } foreach ($response['headers'] as $headerName => $value) { if (strtolower($headerName) == "content-type") { $ContentType = $value; break; } } // Check content type if (!preg_match('/image/', $ContentType)) { // wrong URL return new PEAR_Error(getGS('URL "$1" is invalid or is not an image.', $p_url)); } // Save the file $tmpname = $Campsite['TMP_DIRECTORY'].'img'.md5(rand()); if (is_writable($Campsite['TMP_DIRECTORY'])) { if ($tmphandle = fopen($tmpname, 'w')) { fwrite($tmphandle, $response['body']); fclose($tmphandle); } } else { return new PEAR_Error(camp_get_error_message(CAMP_ERROR_CREATE_FILE, $tmpname), CAMP_ERROR_CREATE_FILE); } // Check if it is really an image file $imageInfo = getimagesize($tmpname); if ($imageInfo === false) { unlink($tmpname); return new PEAR_Error(getGS('URL "$1" is not an image.', $cURL)); } // content-type = image if (!is_null($p_id)) { // Updating the image $image = new Image($p_id); $image->update($p_attributes); // Remove the old image & thumbnail because // the new file might have a different file extension. if (file_exists($image->getImageStorageLocation())) { if (is_writable(dirname($image->getImageStorageLocation()))) { unlink($image->getImageStorageLocation()); } else { return new PEAR_Error(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $image->getImageStorageLocation()), CAMP_ERROR_DELETE_FILE); } } if (file_exists($image->getThumbnailStorageLocation())) { if (is_writable(dirname($image->getThumbnailStorageLocation()))) { unlink($image->getThumbnailStorageLocation()); } else { return new PEAR_Error(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $image->getThumbnailStorageLocation()), CAMP_ERROR_DELETE_FILE); } } } else { // Creating the image $image = new Image(); $image->create($p_attributes); $image->setProperty('TimeCreated', 'NULL', true, true); $image->setProperty('LastModified', 'NULL', true, true); } if (!isset($p_attributes['Date'])) { $image->setProperty('Date', 'NOW()', true, true); } $image->setProperty('Location', 'remote', false); $image->setProperty('URL', $p_url, false); if (isset($imageInfo['mime'])) { $image->setProperty('ContentType', $imageInfo['mime'], false); } // Remember who uploaded the image if (!is_null($p_userId)) { $image->setProperty('UploadedByUser', $p_userId, false); } if ($Campsite['IMAGEMAGICK_INSTALLED']) { // Set thumbnail file name $extension = Image::__ImageTypeToExtension($imageInfo[2]); $thumbnail = $image->generateThumbnailStorageLocation($extension); $image->setProperty('ThumbnailFileName', basename($thumbnail), false); if (!is_writable(dirname($image->getThumbnailStorageLocation()))) { return new PEAR_Error(camp_get_error_message(CAMP_ERROR_CREATE_FILE, $image->getThumbnailStorageLocation()), CAMP_ERROR_CREATE_FILE); } // Create the thumbnail $cmd = $Campsite['THUMBNAIL_COMMAND'].' ' . $tmpname . ' ' . $image->getThumbnailStorageLocation(); system($cmd); if (file_exists($image->getThumbnailStorageLocation())) { chmod($image->getThumbnailStorageLocation(), 0644); } } unlink($tmpname); $image->commit(); $logtext = getGS('The image $1 has been added.', $image->m_data['Description']." (".$image->m_data['Id'].")"); Log::Message($logtext, null, 41); return $image; } // fn OnAddRemoteImage
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; }
if ($cSubs == "d") { $numSubscriptionsDeleted = Subscription::DeleteSubscriptionsInSection($Pub, $Section); if ($numSubscriptionsDeleted < 0) { $errors[] = getGS('Error updating subscriptions.'); } } $conflictingSection = array_pop(Section::GetSections($Pub, $Issue, $Language, $cShortName, null, null, true)); if (is_object($conflictingSection) && ($conflictingSection->getSectionNumber() != $Section)) { $conflictingSectionLink = "/$ADMIN/sections/edit.php?Pub=$Pub&Issue=$Issue&Language=$Language&Section=".$conflictingSection->getSectionNumber(); $msg = getGS('The URL name must be unique for all sections in this issue.<br>The URL name you specified ("$1") conflicts with section "$2$3. $4$5"', $cShortName, "<a href='$conflictingSectionLink' class='error_message' style='color:#E30000;'>", $conflictingSection->getSectionNumber(), htmlspecialchars($conflictingSection->getName()), "</a>"); camp_html_add_msg($msg); // placeholder for localization string - we might need this later. // getGS("The section could not be changed."); } else { $modified &= $sectionObj->setUrlName($cShortName); camp_html_add_msg(getGS("Section updated"), "ok"); } $logtext = getGS('Section "$1" ($2) updated. (Publication: $3, Issue: $4)', $cName, $Section, $publicationObj->getPublicationId(), $issueObj->getIssueNumber()); Log::Message($logtext, $g_user->getUserId(), 21); } camp_html_goto_page($editUrl); ?>
/** * Set the topic name for the given language. A new entry in * the database will be created if the language does not exist. * * @param int $p_languageId * @param string $p_value * * @return boolean */ public function setName($p_languageId, $p_value) { global $g_ado_db; if (!is_string($p_value) || !is_numeric($p_languageId)) { return false; } if (isset($this->m_names[$p_languageId])) { // Update the name. $oldName = $this->m_names[$p_languageId]->getName(); $changed = $this->m_names[$p_languageId]->setName($p_value); } else { $topicName = new TopicName($this->getTopicId(), $p_languageId); $changed = $topicName->create(array('name'=>$p_value)); $this->m_names[$p_languageId] = $topicName; } if ($changed) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } if (!empty($oldName)) { $logtext = getGS('Topic $1: ("$2" -> "$3") updated', $this->m_data['id'], $oldName, $this->m_names[$p_languageId]); } else { $logtext = getGS('Topic "$1" ($2) added', $this->m_names[$p_languageId], $this->m_data['id']); } Log::Message($logtext, null, 143); } return $changed; } // fn setName