function GetPropertiesFromForm(&$Context) { $this->CategoryID = ForceIncomingInt('CategoryID', 0); $this->Name = ForceIncomingString('Name', ''); $this->Description = ForceIncomingString('Description', ''); $this->AllowedRoles = ForceIncomingArray('CategoryRoleBlock', array()); }
function ApplicantsForm(&$Context) { $this->Name = "ApplicantsForm"; $this->ValidActions = array("Applicants", "ProcessApplicants"); $this->Constructor($Context); if (!$this->Context->Session->User->Permission("PERMISSION_APPROVE_APPLICANTS")) { $this->IsPostBack = 0; } elseif ($this->IsPostBack) { $this->Context->PageTitle = $this->Context->GetDefinition('MembershipApplicants'); // See if the form has been submitted if ($this->PostBackAction == 'ProcessApplicants' && $this->IsValidFormPostBack()) { $Action = ForceIncomingString('btnSubmit', ''); // Compare to language dictionary to figure out exactly what should be done if ($Action != '') { $Action = $Context->GetDefinition('ApproveForMembership') == $Action ? 'Approve' : 'Decline'; } // Retrieve the id's to manipulate $ApplicantIDs = ForceIncomingArray('ApplicantID', array()); // Approve or decline the applicants if ($Action != '' && is_array($ApplicantIDs) && count($ApplicantIDs) > 0) { $um = $this->Context->ObjectFactory->NewContextObject($this->Context, 'UserManager'); if ($Action == 'Approve') { $um->ApproveApplicant($ApplicantIDs); } else { $um->RemoveApplicant($ApplicantIDs); } } } // There is no need to load all of the applicants since they were already loaded by the settings.php page // $um = $this->Context->ObjectFactory->NewContextObject($this->Context, 'UserManager'); // $this->ApplicantData = $um->GetUsersByRoleId(0); } $this->CallDelegate("Constructor"); }
<?php /* * Copyright 2003 Mark O'Sullivan * This file is part of Vanilla. * Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. * Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * The latest source code for Vanilla is available at www.lussumo.com * Contact Mark O'Sullivan at mark [at] lussumo [dot] com * * Description: File used by Dynamic Data Management object to change the order of categories */ include '../appg/settings.php'; include '../appg/init_ajax.php'; $Sql = 'update ' . $Configuration['DATABASE_TABLE_PREFIX'] . "Category set Priority = '//1' where CategoryID = '//2';"; $SortOrder = ForceIncomingArray('CategoryID', array()); $ItemCount = count($SortOrder); for ($i = 0; $i < $ItemCount; $i++) { $ExecSql = str_replace(array('//1', '//2'), array($i, $SortOrder[$i]), $Sql); $Context->Database->Execute($ExecSql, 'AJAX', 'ReorderCategories', 'Failed to reorder categories', 0); } $Context->Unload();
* Copyright 2003 Mark O'Sullivan * This file is part of Vanilla. * Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. * Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * The latest source code for Vanilla is available at www.lussumo.com * Contact Mark O'Sullivan at mark [at] lussumo [dot] com * * Description: File used by Dynamic Data Management object to change the order of roles */ include '../appg/settings.php'; include '../appg/init_ajax.php'; $PostBackKey = ForceIncomingString('PostBackKey', ''); if ($PostBackKey = '' || $PostBackKey !== $Context->Session->GetCsrfValidationKey()) { die($Context->GetDefinition('ErrPostBackKeyInvalid')); } if (!$Context->Session->User->Permission('PERMISSION_SORT_ROLES')) { die($Context->GetDefinition('ErrPermissionSortRoles')); } $Sql = 'update ' . GetTableName('Role', $DatabaseTables, $Configuration["DATABASE_TABLE_PREFIX"]) . ' set ' . $DatabaseColumns['Role']['Priority'] . " = '//1' where " . $DatabaseColumns['Role']['RoleID'] . " = '//2';"; $SortOrder = ForceIncomingArray('RoleID', array()); $ItemCount = count($SortOrder); for ($i = 0; $i < $ItemCount; $i++) { $RoleID = ForceInt($SortOrder[$i], null); if ($RoleID !== null) { $ExecSql = str_replace(array('//1', '//2'), array($i, $RoleID), $Sql); $Context->Database->Execute($ExecSql, 'AJAX', 'ReorderRoles', 'Failed to reorder roles', 0); } } echo $SortOrder; $Context->Unload();
function RoleForm(&$Context) { $this->Name = 'RoleForm'; $this->CategoryBoxes = ''; $this->ValidActions = array('Roles', 'Role', 'ProcessRole', 'RoleRemove', 'ProcessRoleRemove'); $this->Constructor($Context); $this->CategoryData = false; if ($this->IsPostBack) { $RedirectUrl = ''; $this->Context->PageTitle = $this->Context->GetDefinition('RoleManagement'); // Add the javascript to the head for sorting roles if ($this->PostBackAction == "Roles") { global $Head; $Head->AddScript('js/prototype.js'); $Head->AddScript('js/scriptaculous.js'); } $RoleID = ForceIncomingInt('RoleID', 0); $ReplacementRoleID = ForceIncomingInt('ReplacementRoleID', 0); $this->RoleManager = $this->Context->ObjectFactory->NewContextObject($this->Context, 'RoleManager'); if ($this->PostBackAction == 'ProcessRole' && $this->IsValidFormPostBack() && ($RoleID == 0 && $this->Context->Session->User->Permission('PERMISSION_ADD_ROLES') || $RoleID > 0 && $this->Context->Session->User->Permission('PERMISSION_EDIT_ROLES'))) { $this->Role = $this->Context->ObjectFactory->NewContextObject($this->Context, 'Role'); $this->Role->GetPropertiesFromForm($this->Context->Configuration); $NewRole = $this->RoleManager->SaveRole($this->Role); if ($NewRole) { if ($RoleID == 0) { $IncomingCategories = ForceIncomingArray('AllowedCategoryID', array()); $IncomingCategories[] = 0; // Look for incoming category role blocks to assign. $s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder'); $s->SetMainTable('Category', 'c'); $s->AddSelect('CategoryID', 'c'); $s->AddWhere('c', 'CategoryID', '', '(' . implode(',', $IncomingCategories) . ')', 'not in', 'and', '', 0); $BlockedCategories = $this->Context->Database->Select($s, 'RoleForm', 'Constructor', 'An error occurred while retrieving blocked categories.'); while ($Row = $this->Context->Database->GetRow($BlockedCategories)) { $CategoryID = ForceInt($Row['CategoryID'], 0); if ($CategoryID > 0) { $s->Clear(); $s->SetMainTable('CategoryRoleBlock', 'crb'); $s->AddFieldNameValue('CategoryID', $CategoryID); $s->AddFieldNameValue('RoleID', $NewRole->RoleID); $s->AddFieldNameValue('Blocked', 1); $this->Context->Database->Insert($s, $this->Name, 'SaveCategory', 'An error occurred while adding new category block definitions for this role.'); } } $RedirectUrl = GetUrl($this->Context->Configuration, $this->Context->SelfUrl, '', '', '', '', 'PostBackAction=Roles&Action=SavedNew'); } else { $RedirectUrl = GetUrl($this->Context->Configuration, $this->Context->SelfUrl, '', '', '', '', 'PostBackAction=Roles&Action=Saved'); } } } elseif ($this->PostBackAction == 'ProcessRoleRemove' && $this->Context->Session->User->Permission('PERMISSION_REMOVE_ROLES') && $this->IsValidFormPostBack()) { if ($this->RoleManager->RemoveRole($RoleID, $ReplacementRoleID)) { $RedirectUrl = GetUrl($this->Context->Configuration, $this->Context->SelfUrl, '', '', '', '', 'PostBackAction=Roles&Action=Removed'); } } if (in_array($this->PostBackAction, array('RoleRemove', 'Roles', 'Role', 'ProcessRole', 'ProcessRoleRemove'))) { $GetUnauthenticatedRole = 1; if (in_array($this->PostBackAction, array('RoleRemove', 'ProcessRoleRemove'))) { $GetUnauthenticatedRole = 0; } $this->RoleData = $this->RoleManager->GetRoles('', $GetUnauthenticatedRole); } if (in_array($this->PostBackAction, array('RoleRemove', 'Role', 'ProcessRoleRemove', 'ProcessRole'))) { $this->RoleSelect = $this->Context->ObjectFactory->NewObject($this->Context, 'Select'); $this->RoleSelect->Name = 'RoleID'; $this->RoleSelect->CssClass = 'SmallInput'; $this->RoleSelect->AddOption('', $this->Context->GetDefinition('Choose')); $this->RoleSelect->AddOptionsFromDataSet($this->Context->Database, $this->RoleData, 'RoleID', 'Name'); } if ($this->PostBackAction == 'Role') { if ($RoleID > 0) { $this->Role = $this->RoleManager->GetRoleById($RoleID); } else { $this->Role = $this->Context->ObjectFactory->NewContextObject($this->Context, 'Role'); } } if (in_array($this->PostBackAction, array('ProcessRole', 'ProcessRoleRemove'))) { // Show the form again with errors $this->PostBackAction = str_replace('Process', '', $this->PostBackAction); } if ($this->PostBackAction == 'Role' && $RoleID == 0) { // Load all Categories $cm = $this->Context->ObjectFactory->NewContextObject($this->Context, 'CategoryManager'); $this->CategoryData = $cm->GetCategories(); } if ($RedirectUrl) { //@todo: should the process die here? Redirect($RedirectUrl, '302', '', 0); } } $this->CallDelegate('Constructor'); }
</li>'; while (list($PermissionKey, $PermissionValue) = each($this->Role->Permissions)) { echo '<li> <p> <span>' . GetDynamicCheckBox($PermissionKey, 1, $PermissionValue, '', $this->Context->GetDefinition($PermissionKey)) . '</span> </p> </li>'; } // Add the option of specifying which categories this role can see if creating a new role if ($this->Role->RoleID == 0 && $this->CategoryData) { echo '<li> <p class="Description"> <br /><strong>' . $this->Context->GetDefinition('RoleCategoryNotes') . '</strong> </p> </li> <li> <p class="Description"> ' . $this->Context->GetDefinition('Check') . " <a href=\"./\" onclick=\"CheckAll('AllowedCategoryID'); return false;\">" . $this->Context->GetDefinition('All') . '</a>, ' . " <a href=\"./\" onclick=\"CheckNone('AllowedCategoryID'); return false;\">" . $this->Context->GetDefinition('None') . '</a> </p> </li>'; while ($Row = $this->Context->Database->GetRow($this->CategoryData)) { echo '<li> <p> <span>' . GetDynamicCheckBox('AllowedCategoryID[]', $Row['CategoryID'], in_array($Row['CategoryID'], ForceIncomingArray('AllowedCategoryID', array())), '', $Row['Name'], '', 'AllowedCategoryID' . $Row['CategoryID']) . '</span> </p> </li>'; } } } $this->CallDelegate('PreSubmitButton'); echo '</ul>
function GenerateThumbnails() { // $this->DefineBrowsingDirectory(); // Retrieve incoming ImageIDs to thumbnail $ImagesToThumbnail = ForceIncomingArray("ImageID", array()); // Find those images in the current folder $ThumbnailCollection = array(); $FileCounter = 0; $Files = $this->ImageCollection->GetFiles($this->SortBy, $this->SortDirection, $ThumbnailCollection); $BatchSize = count($ImagesToThumbnail); $BatchIncrement = 1; if ($BatchSize > 10) { $BatchSize = 10; } if ($BatchSize > 0) { for ($j = 0; $j < count($Files); $j++) { $FileCounter += 1; $CurrentFileName = $Files[$j]["Name"]; $CurrentFileSize = $Files[$j]["Size"]; $CurrentFileDate = $Files[$j]["Date"]; $CurrentFileHandlerMethod = $Files[$j]["HandlerMethod"]; if (in_array($FileCounter, $ImagesToThumbnail)) { // Generate the thumbnail $this->GenerateThumbnail($this->GetFileType($this->CurrentBrowsingDirectory, $CurrentFileName), $CurrentFileName, $this->CurrentBrowsingDirectory); // Remove the item from the array $key = array_search($FileCounter, $ImagesToThumbnail); if ($key !== false) { array_splice($ImagesToThumbnail, $key, 1); } $BatchIncrement++; if ($BatchIncrement > $BatchSize) { $j = count($Files); } } } } return $ImagesToThumbnail; }
/** * Create the Nugget coming from New/Edit Nugget page and save the result back in the file */ function CreateNugget(&$NuggetSettings) { $Name = ForceIncomingString('Name', ''); $ID = ForceIncomingInt('ID', 0); $HTML = ForceIncomingString('HTML', ''); $Description = ForceIncomingString('Description', ''); $Position = ForceIncomingString('Position', ''); $HideName = ForceIncomingBool('HideName', 0); $Weight = ForceIncomingInt('Weight', 0); $RoleArr = ForceIncomingArray('AllowedRoles', array()); $PagesArr = ForceIncomingArray('AllowedPages', array()); /*while (list(,$Value) = each($PagesArr)) { if (!in_array($Value, array("settings.php","search.php","account.php","index.php","comments.php","post.php","categories.php"))) { $PagesArr = array_merge($PagesArr, array("extension.php")); break; } }*/ //so the user won't lose any info on error $NuggetSettings->NuggetName = htmlspecialchars($Name); $NuggetSettings->NuggetHTML = htmlspecialchars($HTML); $NuggetSettings->NuggetID = $ID; $NuggetSettings->NuggetPosition = htmlspecialchars($Position); $NuggetSettings->NuggetDescription = htmlspecialchars($Description); $NuggetSettings->NuggetWeight = $Weight; $NuggetSettings->NuggetRoles = $RoleArr; $NuggetSettings->NuggetPages = $PagesArr; $NuggetSettings->NuggetHideName = $HideName; if (!strlen($Name)) { $this->Context->WarningCollector->Add($this->Context->GetDefinition('NuggetObj_NoInputValue')); return 1; } if ($ID == '') { $ID = 100; } //arbitrary high number for ($i = $f = 0; $i < count($this->Nugget); $i++) { if ($this->Nugget[$i]['id'] == $ID && $i != $this->NuggetIndex) { $f = 1; //Nugget already exists break; } } if ($f) { //Display error, since nugget already exists. $this->Context->WarningCollector->Add($this->Context->GetDefinition('NuggetObj_AlreadyCreated')); return 1; } $NewNugget = array('name' => $Name, 'id' => $ID, 'description' => $Description, 'position' => $Position, 'status' => $Position == '[Frozen]' ? 0 : 1, 'hideName' => $HideName, 'html' => $HTML, 'weight' => $Weight, 'roles' => $RoleArr, 'pages' => $PagesArr); if (isset($this->Nugget[$this->NuggetIndex])) { //Overwrite existing nugget $this->Nugget[$this->NuggetIndex] = $NewNugget; } else { // Add a new Nugget $this->Nugget[count($this->Nugget)] = $NewNugget; } $this->SaveNugget(); return 0; }
function RoleForm(&$Context) { $this->CategoryBoxes = ""; $this->ValidActions = array("Roles", "Role", "ProcessRole", "RoleRemove", "ProcessRoleRemove"); $this->Constructor($Context); if (!$this->Context->Session->User->AdminUsers && !$this->Context->Session->User->MasterAdmin) { $this->IsPostBack = 0; } elseif ($this->IsPostBack) { $RoleID = ForceIncomingInt("RoleID", 0); $ReplacementRoleID = ForceIncomingInt("ReplacementRoleID", 0); $this->RoleManager = $this->Context->ObjectFactory->NewContextObject($this->Context, "RoleManager"); if ($this->PostBackAction == "ProcessRole") { $this->Role = $this->Context->ObjectFactory->NewObject($this->Context, "Role"); $this->Role->GetPropertiesFromForm($this->Context); $NewRole = $this->RoleManager->SaveRole($this->Role); if ($NewRole) { if ($RoleID == 0) { $IncomingCategories = ForceIncomingArray("AllowedCategoryID", array()); $IncomingCategories[] = 0; // Look for incoming category role blocks to assign. $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder"); $s->SetMainTable("Category", "c"); $s->AddSelect("CategoryID", "c"); $s->AddWhere("CategoryID", "(" . implode(",", $IncomingCategories) . ")", "not in", "and", "", 0); $BlockedCategories = $this->Context->Database->Select($this->Context, $s, "RoleForm", "Constructor", "An error occurred while retrieving blocked categories."); while ($Row = $this->Context->Database->GetRow($BlockedCategories)) { $CategoryID = ForceInt($Row["CategoryID"], 0); if ($CategoryID > 0) { $s->Clear(); $s->SetMainTable("CategoryRoleBlock", "crb"); $s->AddFieldNameValue("CategoryID", $CategoryID); $s->AddFieldNameValue("RoleID", $NewRole->RoleID); $s->AddFieldNameValue("Blocked", 1); $this->Context->Database->Insert($this->Context, $s, $this->Name, "SaveCategory", "An error occurred while adding new category block definitions for this role."); } } } header("location: settings.php?PostBackAction=Roles"); } } elseif ($this->PostBackAction == "ProcessRoleRemove") { if ($this->RoleManager->RemoveRole($RoleID, $ReplacementRoleID)) { header("location: settings.php?PostBackAction=Roles"); } } if (in_array($this->PostBackAction, array("RoleRemove", "Roles", "Role", "ProcessRole", "ProcessRoleRemove"))) { $this->RoleData = $this->RoleManager->GetRoles(); } if (in_array($this->PostBackAction, array("RoleRemove", "Role", "ProcessRoleRemove"))) { $this->RoleSelect = $this->Context->ObjectFactory->NewObject($this->Context, "Select"); $this->RoleSelect->Name = "RoleID"; $this->RoleSelect->CssClass = "SmallInput"; $this->RoleSelect->AddOption("", $this->Context->GetDefinition("Choose")); $this->RoleSelect->AddOptionsFromDataSet($this->Context->Database, $this->RoleData, "RoleID", "Name"); } if ($this->PostBackAction == "Role") { if ($RoleID > 0) { $this->Role = $this->RoleManager->GetRoleById($RoleID); } else { $this->Role = $this->Context->ObjectFactory->NewObject($this->Context, "Role"); } } if (in_array($this->PostBackAction, array("ProcessRole", "ProcessRoleRemove"))) { // Show the form again with errors $this->PostBackAction = str_replace("Process", "", $this->PostBackAction); } if ($this->PostBackAction == "Role" && $RoleID == 0) { // Load all Categories $cm = $this->Context->ObjectFactory->NewContextObject($this->Context, "CategoryManager"); $CategoryData = $cm->GetCategories(); while ($Row = $Context->Database->GetRow($CategoryData)) { $this->CategoryBoxes .= "<div class=\"CheckBox\">" . GetDynamicCheckBox("AllowedCategoryID[]", $Row["CategoryID"], in_array($Row["CategoryID"], ForceIncomingArray("AllowedCategoryID", array())), "", $Row["Name"]) . "</div>\r\n"; } } } }