Example #1
0
    public function newMessage($senderUserId, $recipientUserId, $subject, $body, $adminNote = false)
    {
        /**
         * Create a new message.
         *
         * As this is the start of a new message thread, there is no threadMessageId.
         *
         * @author	Mark O'Russa	<*****@*****.**>
         * @param	int		$senderUserId 		The userId of the sender.
         * @param	int		$recipientUserId	The userId of the recipient.
         * @param	varchar	$subject			A short description of the message.
         * @param	text	$body				The message.
         * @param	text	$adminNote			A message intended to help admins with the message. This is not visible to non-adm ins.
         *
         * @return	boolean	Returns a success message, otherwise throws a customException.
         */
        global $debug, $message, $Dbc;
        $sendMessageError = 'We encountered a technical problem and were unable to send the message. Please try again in a few moments.<br>
<br>
If the problem persists please <a href="' . LINKSUPPORT . '">contact support</a>.';
        try {
            $senderUserId = intThis($senderUserId);
            $recipientUserId = intThis($recipientUserId);
            $body = empty($body) ? $this->_body : $body;
            if (empty($senderUserId)) {
                $senderUserId = 1;
                $recipientUserId = 1;
                $subject = 'error trying to create message';
                $adminNote = 'The $senderUserId was empty while trying to create a new message. View debug information in the admin notes.' . $debug->output();
                //throw new Adrlist_CustomException($sendMessageError,'$senderUserId is empty.');
            } elseif (empty($recipientUserId)) {
                $recipientUserId = 1;
                $subject = 'error trying to create message';
                $adminNote = 'The $recipientUserId was empty while trying to create a new message. View debug information in the admin notes.' . $debug->output();
            } elseif (strlen($subject) > 255) {
                throw new Adrlist_CustomException('Please enter a subject shorter than 255 characters.', '$subject too long. The character limit is 255.');
            } elseif (empty($body)) {
                throw new Adrlist_CustomException('Please enter a message.', '$body is empty.');
            } else {
                //Add a new message.
                $newMessageStmt = $Dbc->prepare("INSERT INTO\n\tmessageCenter\nSET\n\tsenderUserId = ?,\n\trecipientUserId = ?,\n\tsentDatetime = ?,\n\tsubject = ?,\n\tmessage = ?,\n\tadminNote = ?");
                $newMessageParams = array($senderUserId, $recipientUserId, DATETIME, $subject, $body, $adminNote);
                $newMessageStmt->execute($newMessageParams);
                return 'Your message was sent.';
            }
        } catch (Adrlist_CustomException $e) {
            $myFile = __DIR__ . '../CustomLogs/MessageCenter' . __LINE__ . '.txt';
            $fh = fopen($myFile, 'w');
            fwrite($fh, $debug->output());
        } catch (PDOException $e) {
            $debug->add('<pre>' . $e . '</pre>');
            $myFile = __DIR__ . '../CustomLogs/MessageCenter' . __LINE__ . '.txt';
            $fh = fopen($myFile, 'w');
            fwrite($fh, $debug->output());
            error(__LINE__, $sendMessageError, '<pre>' . $e . '</pre>');
        }
    }
Example #2
0
function getFolderInfo($requestingUserId, $folderId)
{
    /*
    Get a folder's information as it relates to a user. The name, created date, modified date, creator, modifier, folderRoleId, and it's lists in an array(listId=>listname).
    $userId = (int) the id of the requesting user. This is to verify the user has role of Member (1) or greater.
    $folderId = (int) the id of the folder.
    Returns (array) of the lists in the folder and the user's role, otherwise (boolean) false. Use === false to check for failure as it's possible a list could be named "0".
    */
    global $debug, $message, $success, $Dbc;
    $output = '';
    try {
        if (empty($requestingUserId)) {
            throw new Adrlist_CustomException('', '$requestingUserId is empty.');
        } elseif (empty($folderId)) {
            throw new Adrlist_CustomException('', '$folderId is empty.');
        }
        $requestingUserId = intThis($requestingUserId);
        $folderId = intThis($folderId);
        //Get the folder's name.
        $stmt = $Dbc->prepare("SELECT\n\tfolders.folderName AS 'folderName',\n\tfolders.cId AS 'cId',\n\tfolders.created AS 'created',\n\tfolders.mId AS 'mId',\n\tfolders.modified AS 'modified',\n\tlists.listId AS 'listId',\n\tlists.listName AS 'listName',\n\tuserFolderSettings.folderRoleId AS 'folderRoleId'\nFROM\n\tuserFolderSettings\nJOIN\n\tfolders ON userFolderSettings.folderId = folders.folderId\nLEFT JOIN\n\tlists ON lists.folderId = userFolderSettings.folderId\nWHERE\n\tuserFolderSettings.userId = ? AND\n\tuserFolderSettings.folderId = ?");
        $params = array($requestingUserId, $folderId);
        $stmt->execute($params);
        $folderArray = array();
        $listArray = array();
        $foundRecords = false;
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            if ($row['folderName'] === '' || $row['folderName'] === NULL) {
                pdoError(__LINE__, $stmt, $params, true);
                return false;
            }
            $folderArray['folderName'] = $row['folderName'];
            $folderArray['cId'] = $row['cId'];
            $folderArray['created'] = $row['created'];
            $folderArray['mId'] = $row['mId'];
            $folderArray['modified'] = $row['modified'];
            $folderArray['folderRoleId'] = empty($row['folderRoleId']) ? 0 : $row['folderRoleId'];
            $listArray[] = array($row['listId'] => $row['listName']);
            $foundRecords = true;
        }
        if (!$foundRecords) {
            return false;
        } else {
            $folderArray['listArray'] = $listArray;
            return $folderArray;
        }
    } catch (Adrlist_CustomException $e) {
    } catch (PDOException $e) {
        error(__LINE__, '', '<pre>' . $e . '</pre>');
        if (MODE !== '') {
            returnData();
        }
    }
    return false;
}
Example #3
0
 public function setDisplayPages($displayPages)
 {
     //The number of pages numbers displayed to the user.
     $this->_displayPages = intThis($displayPages);
 }
Example #4
0
function setSessionVariables($row)
{
    $_SESSION['userId'] = intThis($row['userId']);
    $_SESSION['siteRoleId'] = intThis($row['siteRoleId']);
    $_SESSION['primaryEmail'] = $row['primaryEmail'];
    $_SESSION['secondaryEmail'] = $row['secondaryEmail'];
    $_SESSION['firstName'] = $row['firstName'];
    $_SESSION['lastName'] = $row['lastName'];
    $_SESSION['dateFormat'] = $row['dateFormat'];
    $_SESSION['timeZone'] = $row['timeZone'];
    $_SESSION[UNIQUECOOKIE] = $row['uniqueId'];
}
Example #5
0
 public static function daysDifference($startTime, $endTime)
 {
     $startTime = self::convertToDateTime($startTime);
     $endTime = self::convertToDateTime($endTime);
     $interval = $startTime->diff($endTime);
     return intThis($interval->format('%a'));
 }
function undeleteLine()
{
    global $debug, $message, $success, $Dbc, $returnThis;
    $output = '';
    try {
        if (!isset($_SESSION['listRoleId']) || $_SESSION['listRoleId'] < 2) {
            throw new Adrlist_CustomException("Your role doesn't allow you to edit this list.", '');
        } elseif (empty($_POST['lineId'])) {
            throw new Adrlist_CustomException('', 'lineId is empty.');
        } elseif (empty($_POST['charId'])) {
            throw new Adrlist_CustomException('', 'charName is empty.');
        }
        $Dbc->beginTransaction();
        $updateDeletedLinesStmt = $Dbc->prepare("UPDATE\n\tlinesTable\nSET\n\tlinesTable.dId = NULL,\n\tlinesTable.deleted = NULL\nWHERE\n\tlinesTable.lineId = ?");
        $updateDeletedLinesStmt->execute(array(intThis($_POST['lineId'])));
        $updateDeletedCharactersStmt = $Dbc->prepare("UPDATE\n\tcharacters\nSET\n\tcharacters.dId = NULL,\n\tcharacters.deleted = NULL\nWHERE\n\tcharacters.charId = ?");
        $updateDeletedCharactersStmt->execute(array(intThis($_POST['charId'])));
        $Dbc->commit();
        updateListHist($_SESSION['listId']);
        if (MODE == 'undeleteLine') {
            $success = true;
            $returnThis['buildLines'] = buildLines();
        }
    } catch (Adrlist_CustomException $e) {
    } catch (PDOException $e) {
        error(__LINE__, '', '<pre>' . $e . '</pre>');
    }
    if (MODE == 'undeleteLine') {
        returnData();
    }
}
Example #7
0
function shareListStep1()
{
    global $debug, $message, $success, $Dbc, $returnThis;
    $output = '';
    try {
        if (empty($_POST['listId'])) {
            throw new Adrlist_CustomException('', '$_POST[\'plan\'] is empty.');
        } elseif (!is_numeric($_POST['listId'])) {
            throw new Adrlist_CustomException('', '$_POST[\'plan\'] is not numeric.');
        }
        $_POST['listId'] = intThis($_POST['listId']);
        $listInfo = getListInfo($_SESSION['userId'], $_POST['listId']);
        $debug->printArray($listInfo, '$listInfo');
        if ($listInfo === false || $listInfo['listRoleId'] < 3) {
            //The user must be a manager or owner to share a list.
            throw new Adrlist_CustomException('You must be a manager or owner to share this list.', '');
        }
        $output .= '<div class="myAccountTitle">
	Share List
</div>
Enter the email address of the person you want to share this list with.
<div class="ui-field-contain">
	<label for="shareListInput" unused="ui-hidden-accessible">Email</label>
	<input autocapitalize="off" autocorrect="off" autoreset="true" data-wrapper-class="true" id="shareListInput" goswitch="shareListStep2" name="shareListInput" placeholder="" value="" type="email">
</div>
<button class="ui-btn ui-btn-inline ui-shadow ui-corner-all ui-btn-icon-left ui-icon-heart" id="shareListStep2" listId="' . $_POST['listId'] . '">Save</button>' . cancelButton();
        $returnThis['output'] = $output;
        if (MODE == 'shareListStep1') {
            $success = true;
            returnData();
        }
    } catch (Adrlist_CustomException $e) {
    } catch (PDOException $e) {
        error(__LINE__, '', '<pre>' . $e . '</pre>');
    }
}