コード例 #1
0
	/**
	 * Process
	 * Does all of the work.
	 * This handles processing of the functions. This includes adding, deleting, editing etc.
	 *
	 * @see GetUser
	 * @see User_API::HasAccess
	 * @see GetApi
	 * @see List_API::DeleteAllSubscribers
	 * @see List_API::ChangeSubscriberFormat
	 * @see ManageLists
	 * @see CreateList
	 * @see EditList
	 *
	 * @return Void Handles processing, prints out what it needs to. Doesn't return anything.
	 */
	public function Process()
	{

		// ----- Define and sanitize "common" variables that are used by this function
			$user = GetUser();

			$req_action		= strtolower($this->_getGETRequest('Action', ''));
			$response		= '';
			$parameters 	= array();

			$parameters['user']		= GetUser();
			$parameters['action']	= $req_action;
		// ------

		// ----- Check permissions
			$secondary_actions = array('addlist', 'change', 'processpaging', 'testbouncedisplay', 'testbouncesettings', 'update');
			if (in_array($req_action, $secondary_actions) || empty($req_action)) {
				$access = $user->HasAccess('lists');
			} else {
				$access = $user->HasAccess('lists', $req_action);
			}

			// Check if the user has permission to perform an action on the supplied item.
			// If an item is supplied to the 'update' action then we should treat it like an 'edit' check.
			$effective_action = $req_action;
			if ($req_action == 'update') {
				$effective_action = 'edit';
			}
			if ($access && isset($_GET['id']) && !in_array($effective_action, $secondary_actions)) {
				$access = $user->HasAccess('lists', $effective_action, $_GET['id']);

				if (!$access) {
					$list = array_keys($user->GetLists());
					$access = in_array($_GET['id'], $list);
				}
			}

			if (!$access) {
				$this->PrintHeader();
				$this->DenyAccess();
				$this->PrintFooter();
				return;
			}
		// ------

		// ------ Handle Folders
			$folders = new Folders();
			if (isset($_GET['Mode'])) {
				$folders->SetFolderMode(strtolower($_GET['Mode']));
			}
			unset($folders);
		// ------

		// ------ Set up paging
			if ($req_action == 'processpaging') {
				$this->SetPerPage($_GET['PerPageDisplay']);
				$req_action = '';
			}
		// ------

		$GLOBALS['Message'] = GetFlashMessages();
		$response = '';

		switch ($req_action) {
			case 'copy':
				$response = $this->CopyList($parameters);
			break;

			case 'edit':
				$response = $this->EditList($parameters);
			break;

			case 'update':
				$response = $this->UpdateList($parameters);
			break;

			case 'create':
				// Display the form to create a list
				$response = $this->CreateList($parameters);
			break;

			case 'addlist':
				// Add the list to the system.
				$response = $this->AddList($parameters);
			break;

			case 'change':
				$response = $this->ChangeList($parameters);
			break;

			case 'delete':
				$response = $this->DeleteList($parameters);
			break;

			case 'testbouncesettings':
				$response = $this->TestBounceSettings($parameters);
			break;

			case 'testbouncedisplay':
				$response = $this->TestBounceSettingsDisplay($parameters);
			break;

			default:
				$response = $this->ManageLists($parameters);
			break;
		}

		// Output HTML

		$popup = (in_array($req_action, $this->PopupWindows)) ? true : false;

		if (!in_array($req_action, $this->SuppressHeaderFooter)) {
			$this->PrintHeader($popup);
		}

		echo $response;

		if (!in_array($req_action, $this->SuppressHeaderFooter)) {
			$this->PrintFooter($popup);
		}

	}