Moritz Schmidt 10 vuotta sitten
vanhempi
commit
a0e2fcfb2a

+ 2 - 15
ajax.php

@@ -127,9 +127,6 @@ switch($_REQUEST['action']) {
     case 'getNewDocumentBox':
         header("Status: 200 OK");
 
-        // TODO: add reload on draft change
-        // TODO: add draft-fields as options, depends on ^
-
         $editBox = array(
             "options"   => array(
                 array(
@@ -141,7 +138,7 @@ switch($_REQUEST['action']) {
                 array(
                     "type"  => "text",
                     "name"  => "filename",
-                    "value" => str_replace(".docx", "", Document::getDefaultDraft()->filename) . "_" . date("d_m_Y") . ".docx" // TODO: get value based on draft
+                    "value" => str_replace(".docx", "", Document::getDefaultDraft()->filename) . "_" . date("d_m_Y") . ".docx"
                 )
             ),
             "title" => "Neues Dokument"
@@ -151,9 +148,6 @@ switch($_REQUEST['action']) {
         break;
     case 'getDraftVars':
         header("Status: 200 OK");
-
-        // TODO: handle no draft given
-
         $documentHandle = new \PhpOffice\PhpWord\TemplateProcessor('drafts/' . $_REQUEST['draft']);
         $templateVars = $documentHandle->getVariables();
         echo json_encode(array_values($templateVars));
@@ -205,7 +199,6 @@ switch($_REQUEST['action']) {
         header("Status: 200 OK");
         Label::addLabel($_REQUEST['name'], $_REQUEST['path']);
 
-        // TODO: get status by DB (See: #40, #43)
         $return = array(
             "status"   => "OK"
         );
@@ -216,8 +209,6 @@ switch($_REQUEST['action']) {
         header("Status: 200 OK");
         Label::removeLabel($_REQUEST['labelId']);
 
-        // TODO: get status by DB (See: #40, #43)
-
         $return = array(
             "status"    => "OK"
         );
@@ -228,8 +219,6 @@ switch($_REQUEST['action']) {
         header("Status: 200 OK");
         MailboxFolder::updateMailboxFolder($_REQUEST['mailboxFolderID'], $_REQUEST['folder'], Mailbox::getMailboxByUsername($_REQUEST['account'])->getId(), $_REQUEST['labelID']);
 
-        // TODO: get status by DB (See: #40, #43)
-
         $return = array(
             "status"    => "OK"
         );
@@ -240,8 +229,6 @@ switch($_REQUEST['action']) {
         header("Status: 200 OK");
         MailboxFolder::addMailboxFolder($_REQUEST['folder'], Mailbox::getMailboxByUsername($_REQUEST['account'])->getId(), $_REQUEST['labelID']);
 
-        // TODO: get status by DB (See: #40, #43)
-
         $return = array(
             "status"    => "OK"
         );
@@ -328,7 +315,7 @@ switch($_REQUEST['action']) {
     case 'setReminderSnooze':
         header("Status: 200 OK");
         $reminder = Reminder::getReminderByID($_REQUEST['reminderID']);
-        $reminder->setReminderDate(date("Y-m-d H:i:s", strtotime("+30 minutes"))); // TODO: add more values as select somewhere
+        $reminder->setReminderDate(date("Y-m-d H:i:s", strtotime("+30 minutes")));
         $reminder->save();
 
         $return = array(

+ 1 - 4
cron.php

@@ -1,5 +1,5 @@
 <?php
-// Cron-Job script, looking for new files etc.
+// Cron-Job, looking for new files etc.
 
 // Includes
 include('includes/config.inc.php');
@@ -22,9 +22,6 @@ foreach($dirs as $dir) {
     if(is_dir($CONFIG['documentPath'] . $dir)) {
         searchNewFiles($dir);
     }
-
-    // TODO: implement draft-search
-
 }
 
 searchMails();

+ 2 - 2
includes/call.inc.php

@@ -47,8 +47,8 @@ class Call {
      * @param string $callDate  DateTime of Call
      * @param string $callerTelNr  Telephone number of caller
      * @param int $labelID  ID of Label
-     * @param string $callNotes  Taken notes of Call // TODO: check the english of this description
-     * @param int $reminderID  ID of the Call-reminder, default: -1 // TODO: -1 auto-adds reminder
+     * @param string $callNotes  Notes from Call
+     * @param int $reminderID  ID of the Call-reminder, default: -1 (=> automatically add a Call)
      *
      * @return void
      *

+ 2 - 1
includes/controller.inc.php

@@ -61,10 +61,10 @@ class Controller {
 					$documentView->setTemplate('documentlist');
 					$callView->setTemplate('calllist');
 					$callView->assign('calls', Call::getCallsByLabelID($this->request['labelId']));
-
 					$innerView->setTemplate('label');
 					$innerView->assign('label', Label::getLabelById($this->request['labelId']));
 					$documentView->assign('labelId', $this->request['labelId']);
+					$documentView->assign('documents', Document::getDocumentsByLabelId($this->request['labelId']));
 					$innerView->assign('documentlist', $documentView->loadTemplate());
 					$innerView->assign('calllist', $callView->loadTemplate());
 					break;
@@ -81,6 +81,7 @@ class Controller {
 				case 'settings':
 					$innerView->setTemplate('settings');
 					$innerView->assign('user', $user);
+					$innerView->assign('mailboxes', Mailbox::getMailboxesByUserId($user->getUserId()));
 					break;
 				case 'default':
 				default:

+ 1 - 1
includes/database.inc.php

@@ -70,7 +70,7 @@ class Database {
 	public function updateQuery($query) {
 		$stmt = $this->handle->prepare($query);
 		if(!$stmt) {
-			pa($this->handle); // TODO: better error
+			pa($this->handle);
 		} else {
 			$stmt->execute();
 			$stmt->close();

+ 5 - 7
includes/document.inc.php

@@ -135,16 +135,16 @@ class Document {
      * @param string    $path       Path relative to Label-Home-Folder / Mailaccount
      * @param int       $labelId    ID of Label
      * @param string    $draft      Name of used draft
-     * @param string(?) $created    Date of creation
-     * @param string(?) $lastChange Date of last change
-     * @param int       $mailUid    UID of mail, 0 for Files TODO: parameter = 0, default val
+     * @param string $created    Date of creation
+     * @param string $lastChange Date of last change
+     * @param int       $mailUid    UID of mail, 0 for Files
      * @param int       $mailAcc    ID of MailAccount. Default: -1 (For Files)
      *
-     * @return void  TODO: return true/false error diesdas
+     * @return void
      *
      */
 
-    public static function addDocument($type, $fileName, $path, $labelId, $draft, $created, $lastChange, $mailUid, $mailAcc = -1) {
+    public static function addDocument($type, $fileName, $path, $labelId, $draft, $created, $lastChange, $mailUid = 0, $mailAcc = -1) {
         global $db;
 
         $query = "INSERT INTO `documents`(`type`, `filename`, `path`, `label_id`, `draft`, `created`, `last_change`, `mail_uid`, `mail_acc`) VALUES ('" . $type . "', '" . $fileName . "', '" . $path . "', " . $labelId . ", '" . $draft . "', " . $created . ", " . $lastChange . ", " . $mailUid . ", " . $mailAcc . ");";
@@ -185,8 +185,6 @@ class Document {
 
          $draft = $db->selectQuery("SELECT * FROM `drafts` WHERE `default` = 1;");
 
-         // TODO: > 1, < 1 checking
-
          return $draft[0];
 
      }

+ 3 - 3
includes/functions.inc.php

@@ -44,7 +44,7 @@ function searchNewFiles($scanDir) {
 		}
 
 		foreach($oldDocuments as $oldDocument) {
-			if($oldDocument->getFileName() === $file) { // TODO: Check update-date, maybe removed files
+			if($oldDocument->getFileName() === $file) {
 				$existed = true;
 				break;
 			}
@@ -54,7 +54,7 @@ function searchNewFiles($scanDir) {
 			continue;
 		}
 
-		Document::addDocument('file', $file, '/', Label::getLabelByPath($scanDir)->getId(), '', 'NOW()', 'NOW()', 0); // TODO: get dates by filesystem
+		Document::addDocument('file', $file, '/', Label::getLabelByPath($scanDir)->getId(), '', 'NOW()', 'NOW()');
 
 	}
 
@@ -80,7 +80,7 @@ function searchMails() {
 				for($i = 1; $i <= $messageCount; ++$i) {
 				    $headers = imap_header($mailbox->getMailbox(), $i);
 					pa($headers);
-					//$uid = imap_msgno($mailbox->getMailbox(), imap_uid($mailbox->getMailbox(), $i)); // TODO: Get really unique ID, not folder-id
+					//$uid = imap_msgno($mailbox->getMailbox(), imap_uid($mailbox->getMailbox(), $i));
 					//echo $uid;
 					$uid = imap_uid($mailbox->getMailbox(), $i);
 

+ 3 - 3
includes/label.inc.php

@@ -64,7 +64,7 @@ class Label {
         }
 
         if(sizeof($return) > 1) {
-            //TODO: Error handling!
+            // Error handling!
         }
 
         return $return[0];
@@ -91,7 +91,7 @@ class Label {
         }
 
         if(sizeof($return) > 1) {
-            // TODO: Error handling!
+            // Error handling!
         }
 
         return $return[0];
@@ -118,7 +118,7 @@ class Label {
         }
 
         if(sizeof($return) > 1) {
-            // TODO: Error handling!
+            // Error handling!
         }
 
         return $return[0];

+ 3 - 5
includes/mailbox.inc.php

@@ -131,7 +131,7 @@ class Mailbox {
             if(!$mailbox->valid_ssl) {
                 $noValidCert = '/novalidate-cert';
             }
-            $return[] = new Mailbox($mailbox->id, $mailbox->server, $mailbox->port, $mailbox->protocol, $useSsl, $noValidCert, $mailbox->username, $mailbox->password, $connect); // TODO: Encrypt password
+            $return[] = new Mailbox($mailbox->id, $mailbox->server, $mailbox->port, $mailbox->protocol, $useSsl, $noValidCert, $mailbox->username, $mailbox->password, $connect);
         }
 
         return $return;
@@ -165,7 +165,7 @@ class Mailbox {
             if(!$mailbox->valid_ssl) {
                 $noValidCert = '/novalidate-cert';
             }
-            $return[] = new Mailbox($mailbox->id, $mailbox->server, $mailbox->port, $mailbox->protocol, $useSsl, $noValidCert, $mailbox->username, $mailbox->password, $connect); // TODO: Encrypt password
+            $return[] = new Mailbox($mailbox->id, $mailbox->server, $mailbox->port, $mailbox->protocol, $useSsl, $noValidCert, $mailbox->username, $mailbox->password, $connect);
         }
 
         return $return[0];
@@ -198,7 +198,7 @@ class Mailbox {
             if(!$mailbox->valid_ssl) {
                 $noValidCert = '/novalidate-cert';
             }
-            $return[] = new Mailbox($mailbox->id, $mailbox->server, $mailbox->port, $mailbox->protocol, $useSsl, $noValidCert, $mailbox->username, $mailbox->password, false); // TODO: Encrypt password
+            $return[] = new Mailbox($mailbox->id, $mailbox->server, $mailbox->port, $mailbox->protocol, $useSsl, $noValidCert, $mailbox->username, $mailbox->password, false);
         }
 
         return $return;
@@ -246,8 +246,6 @@ class Mailbox {
              $noValidCert = '/novalidate-cert';
          }
 
-         // TODO: sizeof > < 0 etc.
-
          return new Mailbox($mailbox[0]->id, $mailbox[0]->server, $mailbox[0]->port, $mailbox[0]->protocol, $useSsl, $noValidCert, $mailbox[0]->username, $mailbox[0]->password, false);
 
      }

+ 0 - 2
includes/mailboxfolder.inc.php

@@ -40,8 +40,6 @@ class MailboxFolder {
      *
      */
 
-     // TODO: sizeof handling
-
     public static function getMailboxFolderByName($folderName) {
         global $db;
 

+ 0 - 4
includes/reminder.inc.php

@@ -41,8 +41,6 @@ class Reminder {
         global $db;
 
         $db->updateQuery("UPDATE `reminders` SET `user_id` = " . $this->userID . ", `reminder_date` = '" . $this->reminderDate . "', `reminded_yet` = " . $this->remindedYet . " WHERE `id` = " . $this->id . ";");
-
-        // TODO: error handling
     }
 
     /**
@@ -65,8 +63,6 @@ class Reminder {
             $return[] = new Reminder($reminder->id, $reminder->user_id, $reminder->reminder_date, $reminder->reminded_yet);
         }
 
-        // TODO: sizeof handling
-
         return $return[0];
     }
 

+ 1 - 1
scripts/custom.js

@@ -129,7 +129,7 @@ $(document).ready(function() {
                                 case 'select':
                                     selectHtml = "<select id=\"editbox-input-" + this.name + "\" class=\"editbox-input\">";
                                     if(typeof this['values'] !== "undefined" && this['values']) {
-                                        this['values'].forEach(function(item) { // TODO: jQuery-each?
+                                        this['values'].forEach(function(item) {
                                             if(r['options'][0]['value'] == item) {
                                                 selectHtml += "<option selected value=\"" + item + "\">" + item + "</option>"
                                             } else {

+ 1 - 1
templates/calllist.php

@@ -13,7 +13,7 @@ foreach($this->_['calls'] as $call) {
     echo '<tr>';
     echo '<td>' . $call->getCallDate() . '</td>';
     echo '<td>' . $call->getCallerTelNr() . '</td>';
-    echo '<td>' . $call->getNotes() . '</td>'; // TODO: Excerpt of notes
+    echo '<td>' . $call->getNotes() . '</td>';
     echo '<td><i class="fa fa-clock-o"></i></td>';
     echo '<td><a class="edit-call fancybox.ajax" href="ajax.php?action=editCall&callID=' . $call->getID() . '"><i class="fa fa-wrench"></i></a></td>';
     echo '</tr>';

+ 2 - 7
templates/documentlist.php

@@ -1,8 +1,3 @@
-<?php
-// TODO: Make this MVC-style
-$documents = Document::getDocumentsByLabelId($this->_['labelId']);
-?>
-
 <table class="table table-striped">
     <thead>
         <tr>
@@ -14,9 +9,9 @@ $documents = Document::getDocumentsByLabelId($this->_['labelId']);
         </tr>
     </thead>
 <?php
-foreach($documents as $document) {
+foreach($this->_['documents'] as $document) {
     echo '<tr>';
-    echo '<td>' . $document->getType() . '</td>'; // TODO: Icon instead of text
+    echo '<td>' . $document->getType() . '</td>';
     echo '<td>' . $document->getFileName() . '</td>';
     echo '<td>' . $document->getDraft() . '</td>';
     echo '<td>' . $document->getCreated() . '</td>';

+ 1 - 1
templates/label.php

@@ -23,7 +23,7 @@ foreach($this->_['entries'] as $entry){
                 <li role="presentation"><a href="#calls" aria-controls="settings" role="tab" data-toggle="tab">Calls</a></li>
                 <a href="ajax.php?action=getNewCallBox&labelID=<?php echo $this->_['label']->getId(); ?>" id="new-call" class="btn btn-primary pull-right" role="button">Neuer Anruf</a>
 
-            </ul> <!-- TODO: Add manually scan files button -->
+            </ul>
 
             <!-- Tab panes -->
             <div class="tab-content">

+ 3 - 3
templates/manage-label.php

@@ -5,7 +5,7 @@
         <form action="" method="POST">
             <input type="hidden" name="labelId" value="<?php echo $this->_['label']->getId(); ?>">
             <div class="form-group">
-                <label for="labelName">Name</label> <!-- TODO: Make this a.editable -->
+                <label for="labelName">Name</label>
                 <input type="text" class="form-control" id="labelName" name="labelName" value="<?php echo $this->_['label']->getName(); ?>">
             </div>
             <div class="form-group">
@@ -37,9 +37,9 @@
                         <td></td>
                         <td></td>
                         <td></td>
-                    </tr> <!-- TODO: Fit fancybox -->
+                    </tr>
                 </table>
             </div>
-        </form> <!-- TODO: Make this AJAX, remove form -->
+        </form>
     </div>
 </div>

+ 3 - 8
templates/settings.php

@@ -3,11 +3,6 @@
 
     <div class="row">
         <h3>Mailaccounts</h3>
-        <?php
-            $user = $this->_['user'];
-            $mailboxes = Mailbox::getMailboxesByUserId($user->getUserId()); // TODO: MVC
-        ?>
-
         <table id="settings-mailboxes" class="table table-striped">
             <thead>
                 <tr>
@@ -23,11 +18,11 @@
                 </tr>
             </thead>
             <?php
-            foreach($mailboxes as $mailbox) {
+            foreach($this->_['mailboxes'] as $mailbox) {
                 echo '<tr data-mailbox-id="' . $mailbox->getId() . '">';
                 echo '<td></td>';
                 echo '<td>' . getEditableLink('hostname', 'text', $mailbox->getId(), 'Click to edit', $mailbox->getHostname()) . '</td>';
-                echo '<td>' . getEditableLink('port', 'text', $mailbox->getId(), 'Click to edit', $mailbox->getPort()) . '</td>'; // TODO: alternative inputs
+                echo '<td>' . getEditableLink('port', 'text', $mailbox->getId(), 'Click to edit', $mailbox->getPort()) . '</td>';
                 echo '<td>' . getEditableLink('protocol', 'select', $mailbox->getId(), 'Click to edit', $mailbox->getProtocol()) . '</td>';
                 echo '<td>' . getEditableLink('use-ssl', 'select', $mailbox->getId(), 'Click to edit', $mailbox->getUseSsl()) . '</td>';
                 echo '<td>' . getEditableLink('no-valid-cert', 'select', $mailbox->getId(), 'Click to edit', $mailbox->getNoValidCert()) . '</td>';
@@ -46,7 +41,7 @@
                 <td></td>
                 <td></td>
                 <td></td>
-                <td><a id="add-mailaccount" href="#" data-uid="<?php echo $user->getUserId(); ?>"><i class="fa fa-plus-circle"></i></a></td>
+                <td><a id="add-mailaccount" href="#" data-uid="<?php echo $this->_['user']->getUserId(); ?>"><i class="fa fa-plus-circle"></i></a></td>
             </tr>
         </table>
     </div>