Example #1
0
<?php

include_once "db.php";
include_once "util.php";
include_once "login_filter.php";
include_once 'tables.php';
$budget_id = $_SESSION[SESSION_BUDGET_ID];
$month_id = $_SESSION[SESSION_MONTH_ID];
$folder_id_untrusted = null;
if (filter_input(INPUT_GET, 'folder_id') !== null) {
    $folder_id_untrusted = filter_input(INPUT_GET, 'folder_id');
}
if (filter_input(INPUT_POST, 'folder_id') !== null) {
    $folder_id_untrusted = filter_input(INPUT_POST, 'folder_id');
}
$folder = Folders::load_folder($folder_id_untrusted);
if ($folder_id_untrusted != $folder->id || $folder->budget_id != $budget_id) {
    die("Access Violation");
}
$unsafe_amount = filter_input(INPUT_POST, 'amount');
$unsafe_comment = filter_input(INPUT_POST, 'comment');
$message = "";
if (isset($unsafe_amount)) {
    Entries::add_transaction($folder->budget_id, $folder->id, $month_id, $unsafe_amount, $unsafe_comment);
    $message = "Added";
    header("location: index.php");
    die;
}
include 'header.php';
?>
<div role="main" class="ui-content jqm-content">
Example #2
0
	/**
	 * ManageLists
	 * Prints out the lists for management. This includes deleting subscribers, changing subscriber formats etc.
	 *
	 * @see GetPerPage
	 * @see GetCurrentPage
	 * @see GetSortDetails
	 * @see GetApi
	 * @see User_API::ListAdmin
	 * @see List_API::GetLists
	 * @see User_API::CanCreateList
	 * @see SetupPaging
	 * @see PrintDate
	 *
	 * @param Array $param Any parameters that needed to be passed into this function
	 *
	 * @return String HTML for all the Contact Lists the user has permission to see, paginated.
	 */
	private function ManageLists($param)
	{
		$user =& $param['user'];
		$folders = new Folders();

		if ($folders->InFolderMode()) {
			$perpage = 'all';
			$GLOBALS['Mode'] = 'Folder';
		} else {
			$perpage = $this->GetPerPage();
			$GLOBALS['Mode'] = 'List';
		}

		$DisplayPage = $this->GetCurrentPage();
		$start = 0;
		if ($perpage != 'all') {
			$start = ($DisplayPage - 1) * $perpage;
		}

		$sortinfo = $this->GetSortDetails();

		$all_lists = $user->GetLists();
		$check_lists = array_keys($all_lists);

		$listapi = $this->GetApi('Lists');

		$NumberOfLists = count($check_lists);

		// If we're a list admin, no point checking the lists - we have access to everything.
		if ($user->ListAdmin()) {
			$check_lists = null;
		}

		$mylists = $listapi->GetLists($check_lists, $sortinfo, false, $start, $perpage);

		$GLOBALS['Lists_AddButton'] = '';

		if ($user->CanCreateList() === true) {
			$GLOBALS['Lists_AddButton'] = $this->ParseTemplate('List_Create_Button', true, false);
		}

		if (!isset($GLOBALS['Message'])) {
			$GLOBALS['Message'] = '';
		}

		if ($NumberOfLists == 0) {
			$GLOBALS['Intro'] = GetLang('ListsManage');
			if ($user->CanCreateList() === true) {
				FlashMessage(GetLang('ListCreate'), SS_FLASH_MSG_SUCCESS);
			} else {
				FlashMessage(GetLang('ListAssign'), SS_FLASH_MSG_SUCCESS);
			}
			$GLOBALS['Message'] = GetFlashMessages();
			return $this->ParseTemplate('Lists_Manage_Empty', true);
		}

		$this->SetupPaging($NumberOfLists, $DisplayPage, $perpage);
		$GLOBALS['FormAction'] = 'Action=ProcessPaging';
		$paging = $this->ParseTemplate('Paging', true, false);

		if ($user->HasAccess('Lists', 'Delete')) {
			$GLOBALS['Option_DeleteList'] = '<option value="Delete">' . GetLang('Delete_Lists') . '</option>';
		}

		if ($user->HasAccess('Subscribers', 'Delete')) {
			$GLOBALS['Option_DeleteSubscribers'] = '<option value="DeleteAllSubscribers">' . GetLang('DeleteAllSubscribers') . '</option>';
		}

		$template = $this->ParseTemplate('Lists_Manage', true, false);

		$lists = array();

		foreach ($mylists as $pos => $listinfo) {
			$GLOBALS['Name'] = htmlspecialchars($listinfo['name'], ENT_QUOTES, SENDSTUDIO_CHARSET);
			$GLOBALS['Created'] = $this->PrintDate($listinfo['createdate']);

			$GLOBALS['SubscriberCount'] = $this->FormatNumber($listinfo['subscribecount']);

			$GLOBALS['ListAction'] = '';

			$GLOBALS['ListID'] = $listinfo['listid'];
			$GLOBALS['ListAction'] .= $this->ParseTemplate('Lists_Manage_ViewSubscribersLink', true);

			if ($user->HasAccess('Subscribers', 'Add')) {
				$GLOBALS['AddSubscriberListID'] = $listinfo['listid'];
				$GLOBALS['ListAction'] .= $this->ParseTemplate('Lists_Manage_AddSubscriberLink', true, false);
			}

			if ($listinfo['ownerid'] == $user->userid || $user->HasAccess('Lists', 'Edit', $listinfo['listid'])) {
				$GLOBALS['EditListID'] = $listinfo['listid'];
				$GLOBALS['ListAction'] .= $this->ParseTemplate('Lists_Manage_EditLink', true, false);
			} else {
				$GLOBALS['ListAction'] .= $this->DisabledItem('Edit');
			}

			// This checks whether the user is an admin or list admin, so we don't need to.
			$create_list = $user->CanCreateList();
			if ($create_list === true) {
				$GLOBALS['CopyListID'] = $listinfo['listid'];
				$GLOBALS['ListAction'] .= $this->ParseTemplate('Lists_Manage_Copy', true, false);
			} else {
				if ($create_list === false) {
					$itemtitle = 'ListCopyDisabled';
				} else {
					$itemtitle = 'ListCopyDisabled_TooMany';
				}
				$GLOBALS['ListAction'] .= $this->DisabledItem('Copy', $itemtitle);
			}

			if ($listinfo['ownerid'] == $user->userid || $user->HasAccess('Lists', 'Delete', $listinfo['listid'])) {
				$GLOBALS['DeleteListID'] = $listinfo['listid'];
				$GLOBALS['ListAction'] .= $this->ParseTemplate('Lists_Manage_DeleteLink', true, false);
			} else {
				$GLOBALS['ListAction'] .= $this->DisabledItem('Delete');
			}

			$GLOBALS['List'] = $listinfo['listid'];
			$fullname = GetLang('N/A');
			if ($listinfo['fullname'] != '') {
				$fullname = $listinfo['fullname'];
			} elseif ($listinfo['username'] != '') {
				$fullname = $listinfo['username'];
			}
			$GLOBALS['Fullname'] = htmlspecialchars($fullname, ENT_QUOTES, SENDSTUDIO_CHARSET);

			$listinfo['html'] = $this->ParseTemplate('Lists_Manage_Row', true, false);
			$lists[$listinfo['listid']] = $listinfo;
		}

		if ($folders->InFolderMode()) {

			// Organise the rows into their respective folders.
			$folder_type = 'list';
			$folders_api = $this->GetApi('Folders');
			$folder_list = $folders_api->GetFolderList($folder_type, $user->Get('userid'), $sortinfo);

			// Folder ID 0 is special -- it's the 'Uncategorised' or 'Orphan' folder.
			$folder_list[0]['name'] = GetLang('Folders_OrphanName');

			// Accumulate the HTML for each folder and list.
			$f_html = '';
			$orphan_html = '';
			foreach ($folder_list as $fid=>$folder) {
				$l_html = '';
				if (is_array($folder['items'])) {
					// Loop through $lists, as these will be sorted for us already.
					foreach ($lists as $lid=>$list) {
						if (in_array($lid, $folder['items'])) {
							$l_html .= $list['html'];
						}
					}
				}
				$GLOBALS['Items'] = $l_html;
				$GLOBALS['FolderID'] = $fid;
				$GLOBALS['FolderName'] = htmlspecialchars($folder['name']);
				$GLOBALS['FolderName_Encoded'] = urlencode($folder['name']);
				$GLOBALS['FolderType'] = $folder_type;
				$GLOBALS['Expanded'] = $folder['expanded'];
				if ($fid == 0) {
					if (!$folders->IsOrphanExpanded($folder_type)) {
						$GLOBALS['Expanded'] = 0;
					}
					$orphan_html .= $this->ParseTemplate('Folder', true, false);
					continue;
				}
				$f_html .= $this->ParseTemplate('Folder', true, false);
			}
			// The orphan folder should be put at the end
			$f_html .= $orphan_html;
			$template = str_replace('%%TPL_Lists_Manage_Row%%', $f_html, $template);
			$template = str_replace('%%TPL_Paging%%', '', $template);
			$template = str_replace('%%TPL_Paging_Bottom%%', '', $template);

		} else {

			// Not in folder mode, just print rows.
			$l_html = '';
			foreach ($lists as $list) {
				$l_html .= $list['html'];
			}
			$template = str_replace('%%TPL_Lists_Manage_Row%%', $l_html, $template);
			$template = str_replace('%%TPL_Paging%%', $paging, $template);
			$template = str_replace('%%TPL_Paging_Bottom%%', $GLOBALS['PagingBottom'], $template);
		}
		return $template;
	}
require_once 'endpoints/files.php';
require_once 'endpoints/folders.php';
require_once 'endpoints/formInstance.php';
require_once 'endpoints/formTemplates.php';
require_once 'endpoints/groups.php';
require_once 'endpoints/indexFields.php';
require_once 'endpoints/meta.php';
require_once 'endpoints/parse.php';
require_once 'endpoints/pData.php';
require_once 'endpoints/sites.php';
require_once 'endpoints/users.php';
// CLASS INSTANTIATIONS
$docRequest = new Documents();
$emailRequest = new Emails();
$filesRequest = new Files();
$foldersRequest = new Folders();
$formInstanceRequest = new FormInstance();
$formTemplatesRequest = new FormTemplates();
$groupsRequest = new Groups();
$indexFieldsRequest = new IndexFields();
$metaRequest = new Meta();
$parseRequest = new Parse();
$pdataRequest = new PersistedData();
$sitesRequest = new Sites();
$usersRequest = new Users();
// ------------------------- REQUESTS ---------------------------
// DOCUMENTS
echo $docRequest->deleteDoc('7a6a7f74-3b82-e511-bf04-008cfa482110');
echo $docRequest->getDoc('name%20eq%20%27test%20-2%20-%20test%27');
echo $docRequest->getDocId('e10f2106-8c72-e511-befe-98991b71acc0');
echo $docRequest->getDocIdRev('3c7168e7-4b82-e511-bf04-008cfa482110');
Example #4
0
    } else {
        $folder_id = Folders::create_folder($budget_id, $name);
    }
    header("location: add_transaction.php?folder_id=" . $folder_id);
    die;
}
include 'header.php';
?>
<div role="main" class="ui-content jqm-content">
<p>Select Folder</p>
    <form class="ui-filterable" method="post" data-ajax="false">
    <input type="text" data-type="search" id="autocomplete-input" name="folder">

<ul data-role="listview" data-filter="true"
    data-filter-reveal="true" data-input="#autocomplete-input">
    <?php 
$folders = Folders::folders_for_budget($budget_id);
foreach ($folders as $folder) {
    echo '<li><a href="add_transaction.php?folder_id=' . $folder->id . '">' . $folder->name . '</a></li>';
}
?>
</ul>
        <br>

    <Input type="submit" value="New Folder">
</form>
    <a href="summary.php">Month Summary</a><br>
    <a href="projection.php">Projection</a></br>
</div>
<?php 
include 'footer.php';
Example #5
0
        array_push($known_folders, $p->folder_id);
    }
}
foreach ($entries as $e) {
    $summary_by_folder[$e->folder_id] = $e;
    if (!in_array($e->folder_id, $known_folders)) {
        array_push($known_folders, $e->folder_id);
    }
}
$html = <<<RGDM
    <table>
        <tr><th>Folder Name</th><th>Projection</th><th>Spent</th></tr>
RGDM;
echo $html;
foreach ($known_folders as $folder_id) {
    $folder = Folders::load_folder($folder_id);
    $p = new Projection();
    $s = new EntrySummary();
    if (array_key_exists($folder_id, $projections_by_folder)) {
        $p = $projections_by_folder[$folder_id];
    }
    if (array_key_exists($folder_id, $summary_by_folder)) {
        $s = $summary_by_folder[$folder_id];
    }
    $folder_name = $folder->name;
    $amount = $p->amount;
    $spent = $s->total;
    $html = <<<RGDM
    <tr><td>{$folder_name}</td><td>{$amount}</td><td>{$spent}</td></tr>
RGDM;
    echo $html;
require_once 'endpoints/files.php';
require_once 'endpoints/folders.php';
require_once 'endpoints/formInstance.php';
require_once 'endpoints/formTemplates.php';
require_once 'endpoints/groups.php';
require_once 'endpoints/indexFields.php';
require_once 'endpoints/meta.php';
require_once 'endpoints/parse.php';
require_once 'endpoints/pData.php';
require_once 'endpoints/sites.php';
require_once 'endpoints/users.php';
// create an object.
$docRequest = new Documents();
$emailRequest = new Emails();
$filesRequest = new Files();
$foldersRequest = new Folders();
$formInstanceRequest = new FormInstance();
$formTemplatesRequest = new FormTemplates();
$groupsRequest = new Groups();
$indexFieldsRequest = new IndexFields();
$metaRequest = new Meta();
$parseRequest = new Parse();
$pdataRequest = new PersistedData();
$sitesRequest = new Sites();
$usersRequest = new Users();
// PARSE RESPONSE
// parseResponse() (single field value returned)
// for the parseResponse method a single field value is returned requested by the field name.
// lets pass in a method to create a folder and store the response as $a.
$a = $foldersRequest->postFolder('folder3', 'folder description', true);
// now we pass in the response to the parseRequest method and request the folderId and store it as $b.