Exemplo n.º 1
0
    static function showEditDirectoryForm($error = null, $directory = null)
    {
        $user = Session::getUser();
        if (count($_POST) == 0) {
            ?>
			<form name="editdirectory" action="" method="post">
				<fieldset>
					<legend>New Directory</legend>	
					Name*: <input type="text" name="name" /> 
					<input type="submit" name="create" value="create" /> <?php 
            if (isset($error["name"])) {
                echo $error["name"];
            }
            ?>
				
				</fieldset>
				<fieldset>
					<legend>Delete Directory</legend>
					Check the directory that you wish delete<br />
					<script type="text/javascript">
						var nomiOriginali;						

						function clickRename(event)
						{
							var id =  parseInt(event.target.id);							
							document.getElementById( id + "name" ).removeAttribute('readOnly');
							document.getElementById( id + "confirm").disabled = false;
							document.getElementById( id + "cancel").disabled = false;
							event.target.disabled = true;
						}

						function clickCancel(event)
						{
							var id =  parseInt(event.target.id);
							document.getElementById( id + "name" ).setAttribute('readOnly','readOnly');
							document.getElementById( id + "confirm" ).disabled = true;
							document.getElementById( id + "rename" ).disabled = false;
							event.target.disabled = true;
						}
					</script>	
					<?php 
            if ($user != false) {
                $directoryarray = MailManager::loadUsersDirectories($user->getID());
                if ($directoryarray != false) {
                    foreach ($directoryarray as $directory) {
                        echo "<input type=\"checkbox\" name=\"exdirar[]\" value=\"" . $directory->getID() . "\" />\n\t\t\t\t\t\t\t\t\t\t<input type=\"text\" readonly=\"readonly\" id=\"" . $directory->getID() . "name\" name=\"" . $directory->getName() . "\" value=\"" . $directory->getName() . "\" />\n\t\t\t\t\t\t\t\t\t\t<button type=\"button\" id=\"" . $directory->getID() . "rename\" onclick=\"clickRename(event);\" >rename</button>\n\t\t\t\t\t\t\t\t\t\t<input type=\"submit\" id=\"" . $directory->getID() . "confirm\" name=\"" . $directory->getName() . "\" value=\"confirm\" disabled=\"disabled\" />\n\t\t\t\t\t\t\t\t\t\t<button id=\"" . $directory->getID() . "cancel\" disabled=\"disabled\"  onclick=\"clickCancel(event);\" />cancel</button><br />";
                    }
                }
            }
            ?>
					<input type="submit" name="delete" value="delete" />				
				</fieldset>
			</form>
			<?php 
        } else {
            $error = array();
            if (isset($_POST["create"]) && $_POST["create"] == "create") {
                if (isset($_POST["name"]) && $_POST["name"] !== "") {
                    MailManager::createDirectory($_POST["name"], $user->getID());
                    return true;
                } else {
                    $error["name"] = "it's obbligatory";
                    $_POST = array();
                    self::showEditDirectoryForm($error, $directory);
                }
            }
            if (isset($_POST["delete"]) && $_POST["delete"] == "delete") {
                if ($user != false) {
                    //loadDirectory(,$user);
                    MailManager::deleteDirectory();
                }
            }
        }
    }
Exemplo n.º 2
0
 function testDeleteDirectory()
 {
     $data = $this->mail_data;
     $mail = MailManager::createMail($data);
     $dir = MailManager::createDirectory($this->dir_name, $this->author_id);
     $mailbox = MailManager::loadDirectoryFromName(MAILBOX, $this->author_id);
     $oldmailboxcount = count($dir->getMails());
     //echo "<p>" . $mail . "<br />" . $dir . "</p>"; //DEBUG
     if ($dir == null || $dir === false) {
         return "<br />Directory test NOT PASSED: not created";
     }
     $dir2 = MailManager::deleteDirectory($dir);
     $dir = MailManager::loadDirectory($dir2->getID());
     $mailbox2 = MailManager::loadDirectoryFromName(MAILBOX, $this->author_id);
     //echo "<p>" . $mailbox . "<br />" . $mailbox2 . "</p>"; //DEBUG
     if ($dir !== false) {
         return "<br />Directory test NOT PASSED: not deleted";
     }
     if (count($mailbox2->getMails()) == $oldmailboxcount) {
         return "<br />Directory test NOT PASSED: not moved to Mailbox";
     }
     return "<br />Directory deleting test passed";
 }
Exemplo n.º 3
0
 private static function doDirectoryAction($request)
 {
     require_once 'mail/MailManager.php';
     if (isset(self::$currentID) && self::$currentID != null) {
         self::$currentObject = MailManager::loadDirectory(self::$currentID);
     }
     switch (self::$requestedAction) {
         case "Edit":
             require_once 'mail/MailPage.php';
             MailPage::showEditDirectoryForm(self::$currentObject);
             break;
         case "Mails":
             require_once 'mail/MailPage.php';
             foreach (self::$currentObject->getMails() as $mail) {
                 MailPage::showShortMail($mail);
             }
             break;
         case "Delete":
             MailManager::deleteDirectory(self::$currentObject);
             $inbox = MailManager::loadDirectoryFromName(MAILBOX, self::$currentObject->getUser());
             header("location: " . FileManager::appendToRootPath("Directory/" . $inbox->getID()));
             break;
         case "Sent":
             $mails = MailManager::getMailSent(self::$user);
             foreach ($mails->getMails() as $mail) {
                 MailPage::showShortMail($mail);
             }
             break;
         case "Unread":
             //@deprecated non ce n'è bisogno...
             $inbox = MailManager::loadDirectoryFromName(MAILBOX, self::$user);
             header("location: " . FileManager::appendToRootPath("Directory/" . $inbox->getID()));
             break;
         case "New":
             require_once 'mail/MailPage.php';
             MailPage::showNewDirectoryForm();
             break;
         case "Search":
         default:
             require_once 'search/SearchPage.php';
             SearchPage::showMailSearchForm();
             break;
     }
 }