diff --git a/app/config/database.php b/app/config/database.php index 48096fb..0594e74 100644 --- a/app/config/database.php +++ b/app/config/database.php @@ -2,123 +2,123 @@ return array( - /* - |-------------------------------------------------------------------------- - | PDO Fetch Style - |-------------------------------------------------------------------------- - | - | By default, database results will be returned as instances of the PHP - | stdClass object; however, you may desire to retrieve records in an - | array format for simplicity. Here you can tweak the fetch style. - | - */ - - 'fetch' => PDO::FETCH_CLASS, - - /* - |-------------------------------------------------------------------------- - | Default Database Connection Name - |-------------------------------------------------------------------------- - | - | Here you may specify which of the database connections below you wish - | to use as your default connection for all database work. Of course - | you may use many connections at once using the Database library. - | - */ - - 'default' => 'mysql', - - /* - |-------------------------------------------------------------------------- - | Database Connections - |-------------------------------------------------------------------------- - | - | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is - | supported by Laravel is shown below to make development simple. - | - | - | All database work in Laravel is done through the PHP PDO facilities - | so make sure you have the driver for your particular database of - | choice installed on your machine before you begin development. - | - */ - - 'connections' => array( - - 'sqlite' => array( - 'driver' => 'sqlite', - 'database' => __DIR__.'/../database/production.sqlite', - 'prefix' => '', - ), - - 'mysql' => array( - 'driver' => 'mysql', - 'host' => 'localhost', - 'database' => 'e_fwd', - 'username' => 'root', - 'password' => '123123', - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - ), - - 'pgsql' => array( - 'driver' => 'pgsql', - 'host' => 'localhost', - 'database' => 'forge', - 'username' => 'forge', - 'password' => '', - 'charset' => 'utf8', - 'prefix' => '', - 'schema' => 'public', - ), - - 'sqlsrv' => array( - 'driver' => 'sqlsrv', - 'host' => 'localhost', - 'database' => 'database', - 'username' => 'root', - 'password' => '', - 'prefix' => '', - ), - - ), - - /* - |-------------------------------------------------------------------------- - | Migration Repository Table - |-------------------------------------------------------------------------- - | - | This table keeps track of all the migrations that have already run for - | your application. Using this information, we can determine which of - | the migrations on disk haven't actually been run in the database. - | - */ - - 'migrations' => 'migrations', - - /* - |-------------------------------------------------------------------------- - | Redis Databases - |-------------------------------------------------------------------------- - | - | Redis is an open source, fast, and advanced key-value store that also - | provides a richer set of commands than a typical key-value systems - | such as APC or Memcached. Laravel makes it easy to dig right in. - | - */ - - 'redis' => array( - - 'cluster' => false, - - 'default' => array( - 'host' => '127.0.0.1', - 'port' => 6379, - 'database' => 0, - ), - - ), + /* + |-------------------------------------------------------------------------- + | PDO Fetch Style + |-------------------------------------------------------------------------- + | + | By default, database results will be returned as instances of the PHP + | stdClass object; however, you may desire to retrieve records in an + | array format for simplicity. Here you can tweak the fetch style. + | + */ + + 'fetch' => PDO::FETCH_CLASS, + + /* + |-------------------------------------------------------------------------- + | Default Database Connection Name + |-------------------------------------------------------------------------- + | + | Here you may specify which of the database connections below you wish + | to use as your default connection for all database work. Of course + | you may use many connections at once using the Database library. + | + */ + + 'default' => 'mysql', + + /* + |-------------------------------------------------------------------------- + | Database Connections + |-------------------------------------------------------------------------- + | + | Here are each of the database connections setup for your application. + | Of course, examples of configuring each database platform that is + | supported by Laravel is shown below to make development simple. + | + | + | All database work in Laravel is done through the PHP PDO facilities + | so make sure you have the driver for your particular database of + | choice installed on your machine before you begin development. + | + */ + + 'connections' => array( + + 'sqlite' => array( + 'driver' => 'sqlite', + 'database' => __DIR__.'/../database/production.sqlite', + 'prefix' => '', + ), + + 'mysql' => array( + 'driver' => 'mysql', + 'host' => 'localhost', + 'database' => 'e_fwd', + 'username' => 'root', + 'password' => '', + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'prefix' => '', + ), + + 'pgsql' => array( + 'driver' => 'pgsql', + 'host' => 'localhost', + 'database' => 'forge', + 'username' => 'forge', + 'password' => '', + 'charset' => 'utf8', + 'prefix' => '', + 'schema' => 'public', + ), + + 'sqlsrv' => array( + 'driver' => 'sqlsrv', + 'host' => 'localhost', + 'database' => 'database', + 'username' => 'root', + 'password' => '', + 'prefix' => '', + ), + + ), + + /* + |-------------------------------------------------------------------------- + | Migration Repository Table + |-------------------------------------------------------------------------- + | + | This table keeps track of all the migrations that have already run for + | your application. Using this information, we can determine which of + | the migrations on disk haven't actually been run in the database. + | + */ + + 'migrations' => 'migrations', + + /* + |-------------------------------------------------------------------------- + | Redis Databases + |-------------------------------------------------------------------------- + | + | Redis is an open source, fast, and advanced key-value store that also + | provides a richer set of commands than a typical key-value systems + | such as APC or Memcached. Laravel makes it easy to dig right in. + | + */ + + 'redis' => array( + + 'cluster' => false, + + 'default' => array( + 'host' => '127.0.0.1', + 'port' => 6379, + 'database' => 0, + ), + + ), ); diff --git a/app/repositories/EloquentEmailsRepository.php b/app/repositories/EloquentEmailsRepository.php index 594791e..530487a 100644 --- a/app/repositories/EloquentEmailsRepository.php +++ b/app/repositories/EloquentEmailsRepository.php @@ -7,217 +7,217 @@ class EloquentEmailsRepository extends EloquentListRepository implements EloquentEmailsRepositoryInterface { - protected $main_sql = null; + protected $main_sql = null; - protected $user; - protected $list; - protected $emails; + protected $user; + protected $list; + protected $emails; - /** - * Main Constructor. - */ - public function __construct() { + /** + * Main Constructor. + */ + public function __construct() { - } + } - /** - * Get all emails. - * @return [type] [description] - */ - public function get_all() { + /** + * Get all emails. + * @return [type] [description] + */ + public function get_all() { - $sql_emails = DB::select( + $sql_emails = DB::select( - "SELECT m.id, m.email_address_id, m.subject, m.body, m.body_html, m.optional_text, m.sender_email, m.reciver_email, - m.fwd_accept, m.sent, - m.x_message_id, m.x_date, m.x_size, m.x_uid, m.x_msgno, m.x_recent, m.x_flagged, m.x_answered, m.x_deleted, - m.x_seen, m.x_draft, m.x_udate, - k_l.keywords + "SELECT m.id, m.email_address_id, m.subject, m.body, m.body_html, m.optional_text, m.sender_email, m.reciver_email, + m.fwd_accept, m.sent, + m.x_message_id, m.x_date, m.x_size, m.x_uid, m.x_msgno, m.x_recent, m.x_flagged, m.x_answered, m.x_deleted, + m.x_seen, m.x_draft, m.x_udate, + k_l.keywords - FROM mails m + FROM mails m - INNER JOIN email_address_list e_a_l - ON e_a_l.id = m.email_address_id + INNER JOIN email_address_list e_a_l + ON e_a_l.id = m.email_address_id - INNER JOIN keywords_list k_l - ON k_l.id = e_a_l.keyword_id + INNER JOIN keywords_list k_l + ON k_l.id = e_a_l.keyword_id - GROUP BY m.x_uid - ORDER BY m.id DESC + GROUP BY m.x_uid + ORDER BY m.id DESC - "); + "); - foreach ($sql_emails as $email) { + foreach ($sql_emails as $email) { - $keywords = []; + $keywords = []; - // trim the string - $keywords = trim($email->keywords); + // trim the string + $keywords = trim($email->keywords); - // decode the JSON string - $keywords = json_decode($email->keywords, true); + // decode the JSON string + $keywords = json_decode($email->keywords, true); - // Search the keywords from the email subject - $subject = explode(" ", $email->subject); + // Search the keywords from the email subject + $subject = explode(" ", $email->subject); - // Basically label around the keywords - // -> found in the email's subject. - foreach ($keywords as $keyword) { + // Basically label around the keywords + // -> found in the email's subject. + foreach ($keywords as $keyword) { - if(false !== $key = array_search($keyword, $subject)) { - $subject[$key] = "" . $subject[$key] . ""; - } + if(false !== $key = array_search($keyword, $subject)) { + $subject[$key] = "" . $subject[$key] . ""; + } - } + } - // Put everything back togather + // Put everything back togather $email->subject = implode(" ", $subject); // Conver to easily readable date format $email->utc_time = date('l, d. F Y h:i:s A', $email->x_udate); - } + } - return $sql_emails; + return $sql_emails; - } + } - /** - * Get email by ID. - * @param [type] $id [description] - * @return [type] [description] - */ - public function get_by_id($id = null) { + /** + * Get email by ID. + * @param [type] $id [description] + * @return [type] [description] + */ + public function get_by_id($id = null) { - } + } - /** - * Find recipients by keyword. - * @param [type] $id [description] - * @return [type] [description] - */ - public function find_recipients_by_keyword($id) { - return email_address_list::where("keyword_id", "=", $id); - } + /** + * Find recipients by keyword. + * @param [type] $id [description] + * @return [type] [description] + */ + public function find_recipients_by_keyword($id) { + return email_address_list::where("keyword_id", "=", $id); + } - /** - * Store a new email. - * @param [type] $data [description] - * @return [type] [description] - */ - public function store($data) { + /** + * Store a new email. + * @param [type] $data [description] + * @return [type] [description] + */ + public function store($data) { - $ret = new stdClass(); + $ret = new stdClass(); - try { + try { - if($data != null) { + if($data != null) { - if(!empty($data)) { + if(!empty($data)) { - foreach ($data as $recipent) { + foreach ($data as $recipent) { - if(self::validate($recipent)) { - $ret->data[] = email_address_list::create($recipent); - $ret->error = false; - } + if(self::validate($recipent)) { + $ret->data[] = email_address_list::create($recipent); + $ret->error = false; + } - } + } - return $ret; + return $ret; - } else { - throw new RuntimeException("Error, The array can not be empty", 0.2); - } + } else { + throw new RuntimeException("Error, The array can not be empty", 0.2); + } - } else { - throw new RuntimeException("Errorm The array can not be null", 0.1); - } + } else { + throw new RuntimeException("Errorm The array can not be null", 0.1); + } - } catch(RuntimeException $e) { + } catch(RuntimeException $e) { - $error = new stdClass(); - $error->message = $e->getMessage(); - $error->code = $e->getCode(); - $error->error = true; + $error = new stdClass(); + $error->message = $e->getMessage(); + $error->code = $e->getCode(); + $error->error = true; - return $error; + return $error; - } + } - } + } - /** - * Updaten the email - * @param [type] $data [description] - * @return [type] [description] - */ - public function update($data) { + /** + * Updaten the email + * @param [type] $data [description] + * @return [type] [description] + */ + public function update($data) { - } + } - /** - * Read the email. - * @param [type] $data [description] - * @return [type] [description] - */ - public function read($data) { + /** + * Read the email. + * @param [type] $data [description] + * @return [type] [description] + */ + public function read($data) { - } + } - /** - * Forward single emails. - * @param [type] $data [description] - * @return [type] [description] - */ - public function forward_single($data) { + /** + * Forward single emails. + * @param [type] $data [description] + * @return [type] [description] + */ + public function forward_single($data) { - } + } - /** - * Forward multiple mails. - * @param [type] $data [description] - * @return [type] [description] - */ - public function forward_multiple($data) { - - } - - /** - * Delete single email. - * @param [type] $id [description] - * @return [type] [description] - */ - public function delete_single($id) { - - } - - /** - * Delete multiple messages at a time. - * @param [type] $data [description] - * @return [type] [description] - */ - public function delete_multiple($data) { + /** + * Forward multiple mails. + * @param [type] $data [description] + * @return [type] [description] + */ + public function forward_multiple($data) { + + } + + /** + * Delete single email. + * @param [type] $id [description] + * @return [type] [description] + */ + public function delete_single($id) { + + } + + /** + * Delete multiple messages at a time. + * @param [type] $data [description] + * @return [type] [description] + */ + public function delete_multiple($data) { - } + } - /** - * Remove recipent from the keywords list. - * @param [type] $id [description] - * @return [type] [description] - */ - public function removeRecipent($id) { - return email_address_list::find($id)->delete(); - } + /** + * Remove recipent from the keywords list. + * @param [type] $id [description] + * @return [type] [description] + */ + public function removeRecipent($id) { + return email_address_list::find($id)->delete(); + } - /** - * Validate email_address_loist. - * @return [type] [description] - */ - public static function validate($data) { - $validator = Validator::make($data, email_address_list::$rules); - if($validator->fails()) return $validator->messages(); - return true; - } + /** + * Validate email_address_loist. + * @return [type] [description] + */ + public static function validate($data) { + $validator = Validator::make($data, email_address_list::$rules); + if($validator->fails()) return $validator->messages(); + return true; + } } diff --git a/app/views/list/emails.blade.php b/app/views/list/emails.blade.php index ea483df..ae4633b 100644 --- a/app/views/list/emails.blade.php +++ b/app/views/list/emails.blade.php @@ -3,104 +3,104 @@
- - - | -Subject | -Date | - -- | Emails(<* emails.length *>) | -
---|---|---|---|---|
+ + + | +Subject | +Date | + ++ | Emails(<* emails.length *>) | +
- - - | -- | <* email.utc_time *> | - -- - | -- - Sent - - - | -
+ + + | ++ | <* email.utc_time *> | + ++ + | ++ + Sent + + + | +