Пример #1
0
 /**
  * reset attributes to initial values
  * @return void
  */
 function reset()
 {
     $this->_log->trace("resetting Result");
     $this->error_message_str = "";
     $this->error_log_str = "";
     $this->error_str = "";
     $this->error_element = "";
     $this->result_str = "";
 }
Пример #2
0
 /**
  * pass attributes to User class
  * @return array $list_state_array array containing attribute values of this object
  */
 function pass()
 {
     $list_state_array = array();
     $this->_log->trace("passing ListState (title=" . $this->list_title . ", order=" . $this->order_by_field . ", asc=" . $this->order_ascending . ", page=" . $this->current_page . ")");
     $list_state_array['order_by_field'] = $this->order_by_field;
     $list_state_array['order_ascending'] = $this->order_ascending;
     $list_state_array['archived'] = $this->archived;
     $list_state_array['filter_str'] = $this->filter_str;
     $list_state_array['filter_str_sql'] = $this->filter_str_sql;
     $list_state_array['total_records'] = $this->total_records;
     $list_state_array['total_pages'] = $this->total_pages;
     $list_state_array['current_page'] = $this->current_page;
     $this->_log->trace("passed ListState");
     return $list_state_array;
 }
Пример #3
0
 /**
  * open database connection, select database and return link identifier or FALSE
  * @return resource|bool link identifier or FALSE in case of any error
  */
 function connect()
 {
     $this->_log->trace("opening db connection (host=" . $this->host . ", user="******")");
     $db_link = @mysql_connect($this->host, $this->user, $this->passwd);
     if (!$db_link) {
         $this->error_str = "unable to connect to database (host=" . $this->host . ", user="******")";
         $this->_log->error($this->error_str);
         return FALSE;
     }
     $succes = mysql_select_db($this->database, $db_link);
     if (!$succes) {
         $this->error_str = "unable to select database (db=" . $this->database . ")";
         $this->_log->error($this->error_str);
         return FALSE;
     }
     return $db_link;
 }
 /**
  * remove database table of current DatabaseTable object
  * @return bool indicates if database table has been removed
  */
 function drop()
 {
     $this->_log->trace("drop DatabaseTable (table_name=" . $this->table_name . ")");
     # check if database connection is working
     if ($this->_check_database_connection() == FALSE) {
         return FALSE;
     }
     # check if database table exists
     if (!$this->_database->table_exists($this->table_name)) {
         $this->_handle_error("DatabaseTable does not exist in database", "ERROR_DATABASE_EXISTENCE");
         return FALSE;
     }
     $query = "DROP TABLE " . $this->table_name;
     $result = $this->_database->query($query);
     if ($result == FALSE) {
         $this->_handle_error("could not drop DatabaseTable", "ERROR_DATABASE_PROBLEM");
         return FALSE;
     }
     $this->_log->trace("dropped DatabaseTable (table_name=" . $this->table_name . ")");
     return TRUE;
 }
 /**
  * get html value of specified type of field
  * @param $field_type string type of field
  * @param $field_options string options for given field
  * @param $db_field_name string db field name
  * @param $record array array of record name and values
  * @return string returned html
  */
 function get_field_value($field_type, $field_options, $db_field_name, $record)
 {
     $field_value = $record[$db_field_name];
     $this->_log->trace("get field value (field_type={$field_type}, field_options={$field_options}, db_field_name={$db_field_name}, field_value={$field_value})");
     if ($field_type == FIELD_TYPE_DEFINITION_BOOL) {
         if ($field_value == 0) {
             $html_str = translate("LABEL_NO");
         } else {
             $html_str = translate("LABEL_YES");
         }
     } else {
         if (stristr($field_type, "DATE")) {
             $html_str = str_replace('-', '‑', get_date_str(DATE_FORMAT_FANCY, $field_value, $this->_user->get_date_format()));
         } else {
             if ($field_type == FIELD_TYPE_DEFINITION_AUTO_CREATED) {
                 if ($field_options == NAME_DATE_OPTION_NAME) {
                     $html_str = str_replace('-', '‑', $record[DB_CREATOR_FIELD_NAME]);
                 } else {
                     if ($field_options == NAME_DATE_OPTION_DATE) {
                         $html_str = str_replace('-', '‑', get_date_str(DATE_FORMAT_FANCY, $record[DB_TS_CREATED_FIELD_NAME], $this->_user->get_date_format()));
                     } else {
                         if ($field_options == NAME_DATE_OPTION_DATE_NAME) {
                             $html_str = str_replace('-', '‑', get_date_str(DATE_FORMAT_NORMAL, $record[DB_TS_CREATED_FIELD_NAME], $this->_user->get_date_format()));
                             $html_str .= " (" . $record[DB_CREATOR_FIELD_NAME] . ")";
                         }
                     }
                 }
             } else {
                 if ($field_type == FIELD_TYPE_DEFINITION_AUTO_MODIFIED) {
                     if ($field_options == NAME_DATE_OPTION_NAME) {
                         $html_str = str_replace('-', '‑', $record[DB_MODIFIER_FIELD_NAME]);
                     } else {
                         if ($field_options == NAME_DATE_OPTION_DATE) {
                             $html_str = str_replace('-', '‑', get_date_str(DATE_FORMAT_FANCY, $record[DB_TS_MODIFIED_FIELD_NAME], $this->_user->get_date_format()));
                         } else {
                             if ($field_options == NAME_DATE_OPTION_DATE_NAME) {
                                 $html_str = str_replace('-', '‑', get_date_str(DATE_FORMAT_NORMAL, $record[DB_TS_MODIFIED_FIELD_NAME], $this->_user->get_date_format()));
                                 $html_str .= " (" . $record[DB_MODIFIER_FIELD_NAME] . ")";
                             }
                         }
                     }
                 } else {
                     if ($field_type == FIELD_TYPE_DEFINITION_NOTES_FIELD) {
                         if (count($field_value) > 0) {
                             $html_str = "\n";
                             foreach ($field_value as $note_array) {
                                 $html_str .= "                            <p><span class=\"note_creator\">";
                                 $html_str .= str_replace('-', '&#8209;', get_date_str(DATE_FORMAT_NORMAL, $note_array[DB_TS_CREATED_FIELD_NAME], $this->_user->get_date_format()));
                                 $html_str .= "&nbsp;(" . $note_array[DB_CREATOR_FIELD_NAME] . ")</span> ";
                                 $html_str .= transform_str($note_array["_note"]) . "</p>";
                             }
                         } else {
                             $html_str = "-";
                         }
                     } else {
                         if ($field_type == FIELD_TYPE_DEFINITION_TEXT_FIELD) {
                             $html_str = transform_str($field_value);
                         } else {
                             if ($field_type == FIELD_TYPE_DEFINITION_PASSWORD) {
                                 $html_str = "********";
                             } else {
                                 if ($field_type == FIELD_TYPE_DEFINITION_ATTACHMENTS) {
                                     if ($field_value == 0) {
                                         $html_str = "&nbsp;";
                                     } else {
                                         $html_str = "<span class=\"icon icon_attachment\">&nbsp;</span>";
                                     }
                                 } else {
                                     if ($field_type == FIELD_TYPE_DEFINITION_SELECTION) {
                                         if ($this->configuration[HTML_TABLE_PAGE_TYPE] != PAGE_TYPE_LIST) {
                                             $html_str = translate($field_value);
                                         } else {
                                             $html_str = $field_value;
                                         }
                                     } else {
                                         $html_str = $field_value;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->_log->trace("got field value");
     return $html_str;
 }