From 65c3320bf29bda98916b916b2406fb965d2838ef Mon Sep 17 00:00:00 2001 From: PrameelaBB Date: Tue, 21 Mar 2017 20:09:33 +0530 Subject: [PATCH 1/4] test programs --- reversestring.php | 12 ++++++++++++ sample3.php | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100644 reversestring.php create mode 100644 sample3.php diff --git a/reversestring.php b/reversestring.php new file mode 100644 index 0000000..a95b5c0 --- /dev/null +++ b/reversestring.php @@ -0,0 +1,12 @@ +-1;$i--){ + $rev_str.= $str{$i}; + } + return $rev_str; +} +$str ="my string"; +echo stringRev($str); +?> \ No newline at end of file diff --git a/sample3.php b/sample3.php new file mode 100644 index 0000000..2cc0c26 --- /dev/null +++ b/sample3.php @@ -0,0 +1,6 @@ +"11","pia"=>"12","ram"=>"13"); +print_r(array_change_key_case($namelist,CASE_UPPER)); +print_r(array_chunk($namelist,2)); +?> \ No newline at end of file From f726f264c24ae797861ba267c02512bdde96e83a Mon Sep 17 00:00:00 2001 From: prameela Date: Wed, 19 Apr 2017 18:10:01 +0530 Subject: [PATCH 2/4] school module basic settings with table creation --- LICENSE | 202 ---------- custom/git_module/git_module.info | 9 - custom/git_module/git_module.module | 4 - default.settings.php | 567 +++++++++++++++++++++++++++ files/.htaccess | 15 + gitignore | 23 ++ modules/school/school.info | 4 + modules/school/school.install | 116 ++++++ modules/school/school.module | 54 +++ modules/school/studentImporter.inc | 40 ++ reversestring.php | 12 - sample3.php | 6 - settings.php | 581 ++++++++++++++++++++++++++++ test.txt | 21 - test2.txt | 6 - 15 files changed, 1400 insertions(+), 260 deletions(-) delete mode 100644 LICENSE delete mode 100644 custom/git_module/git_module.info delete mode 100644 custom/git_module/git_module.module create mode 100644 default.settings.php create mode 100644 files/.htaccess create mode 100644 gitignore create mode 100644 modules/school/school.info create mode 100644 modules/school/school.install create mode 100644 modules/school/school.module create mode 100644 modules/school/studentImporter.inc delete mode 100644 reversestring.php delete mode 100644 sample3.php create mode 100644 settings.php delete mode 100644 test.txt delete mode 100644 test2.txt diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 8f71f43..0000000 --- a/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/custom/git_module/git_module.info b/custom/git_module/git_module.info deleted file mode 100644 index 13e62b1..0000000 --- a/custom/git_module/git_module.info +++ /dev/null @@ -1,9 +0,0 @@ -jvbjbvjvjcbvjv -jvjbcjbvcv -jjvjcjv - -fjnfgjg -fdgkkg - -dkgjkjg -dfj diff --git a/custom/git_module/git_module.module b/custom/git_module/git_module.module deleted file mode 100644 index 663554a..0000000 --- a/custom/git_module/git_module.module +++ /dev/null @@ -1,4 +0,0 @@ -gfjsfj -hsdjfjsdhf -sdfjhsdf -sdfksdf diff --git a/default.settings.php b/default.settings.php new file mode 100644 index 0000000..562f998 --- /dev/null +++ b/default.settings.php @@ -0,0 +1,567 @@ + 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'port' => 3306, + * 'prefix' => 'myprefix_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * The "driver" property indicates what Drupal database driver the + * connection should use. This is usually the same as the name of the + * database type, such as mysql or sqlite, but not always. The other + * properties will vary depending on the driver. For SQLite, you must + * specify a database file name in a directory that is writable by the + * webserver. For most other drivers, you must specify a + * username, password, host, and database name. + * + * Transaction support is enabled by default for all drivers that support it, + * including MySQL. To explicitly disable it, set the 'transactions' key to + * FALSE. + * Note that some configurations of MySQL, such as the MyISAM engine, don't + * support it and will proceed silently even if enabled. If you experience + * transaction related crashes with such configuration, set the 'transactions' + * key to FALSE. + * + * For each database, you may optionally specify multiple "target" databases. + * A target database allows Drupal to try to send certain queries to a + * different database if it can but fall back to the default connection if not. + * That is useful for master/slave replication, as Drupal may try to connect + * to a slave server when appropriate and if one is not available will simply + * fall back to the single master server. + * + * The general format for the $databases array is as follows: + * @code + * $databases['default']['default'] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['extra']['default'] = $info_array; + * @endcode + * + * In the above example, $info_array is an array of settings described above. + * The first line sets a "default" database that has one master database + * (the second level default). The second and third lines create an array + * of potential slave databases. Drupal will select one at random for a given + * request as needed. The fourth line creates a new database with a name of + * "extra". + * + * For a single database configuration, the following is sufficient: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => 'main_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * You can optionally set prefixes for some or all database table names + * by using the 'prefix' setting. If a prefix is specified, the table + * name will be prepended with its value. Be sure to use valid database + * characters only, usually alphanumeric and underscore. If no prefixes + * are desired, leave it as an empty string ''. + * + * To have all database names prefixed, set 'prefix' as a string: + * @code + * 'prefix' => 'main_', + * @endcode + * To provide prefixes for specific tables, set 'prefix' as an array. + * The array's keys are the table names and the values are the prefixes. + * The 'default' element is mandatory and holds the prefix for any tables + * not specified elsewhere in the array. Example: + * @code + * 'prefix' => array( + * 'default' => 'main_', + * 'users' => 'shared_', + * 'sessions' => 'shared_', + * 'role' => 'shared_', + * 'authmap' => 'shared_', + * ), + * @endcode + * You can also use a reference to a schema/database as a prefix. This may be + * useful if your Drupal installation exists in a schema that is not the default + * or you want to access several databases from the same code base at the same + * time. + * Example: + * @code + * 'prefix' => array( + * 'default' => 'main.', + * 'users' => 'shared.', + * 'sessions' => 'shared.', + * 'role' => 'shared.', + * 'authmap' => 'shared.', + * ); + * @endcode + * NOTE: MySQL and SQLite's definition of a schema is a database. + * + * Advanced users can add or override initial commands to execute when + * connecting to the database server, as well as PDO connection settings. For + * example, to enable MySQL SELECT queries to exceed the max_join_size system + * variable, and to reduce the database connection timeout to 5 seconds: + * + * @code + * $databases['default']['default'] = array( + * 'init_commands' => array( + * 'big_selects' => 'SET SQL_BIG_SELECTS=1', + * ), + * 'pdo' => array( + * PDO::ATTR_TIMEOUT => 5, + * ), + * ); + * @endcode + * + * WARNING: These defaults are designed for database portability. Changing them + * may cause unexpected behavior, including potential data loss. + * + * @see DatabaseConnection_mysql::__construct + * @see DatabaseConnection_pgsql::__construct + * @see DatabaseConnection_sqlite::__construct + * + * Database configuration format: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'pgsql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'sqlite', + * 'database' => '/path/to/databasefilename', + * ); + * @endcode + */ +$databases = array(); + +/** + * Access control for update.php script. + * + * If you are updating your Drupal installation using the update.php script but + * are not logged in using either an account with the "Administer software + * updates" permission or the site maintenance account (the account that was + * created during installation), you will need to modify the access check + * statement below. Change the FALSE to a TRUE to disable the access check. + * After finishing the upgrade, be sure to open this file again and change the + * TRUE back to a FALSE! + */ +$update_free_access = FALSE; + +/** + * Salt for one-time login links and cancel links, form tokens, etc. + * + * This variable will be set to a random value by the installer. All one-time + * login links will be invalidated if the value is changed. Note that if your + * site is deployed on a cluster of web servers, you must ensure that this + * variable has the same value on each server. If this variable is empty, a hash + * of the serialized database credentials will be used as a fallback salt. + * + * For enhanced security, you may set this variable to a value using the + * contents of a file outside your docroot that is never saved together + * with any backups of your Drupal files and database. + * + * Example: + * $drupal_hash_salt = file_get_contents('/home/example/salt.txt'); + * + */ +$drupal_hash_salt = ''; + +/** + * Base URL (optional). + * + * If Drupal is generating incorrect URLs on your site, which could + * be in HTML headers (links to CSS and JS files) or visible links on pages + * (such as in menus), uncomment the Base URL statement below (remove the + * leading hash sign) and fill in the absolute URL to your Drupal installation. + * + * You might also want to force users to use a given domain. + * See the .htaccess file for more information. + * + * Examples: + * $base_url = 'http://www.example.com'; + * $base_url = 'http://www.example.com:8888'; + * $base_url = 'http://www.example.com/drupal'; + * $base_url = 'https://www.example.com:8888/drupal'; + * + * It is not allowed to have a trailing slash; Drupal will add it + * for you. + */ +# $base_url = 'http://www.example.com'; // NO trailing slash! + +/** + * PHP settings: + * + * To see what PHP settings are possible, including whether they can be set at + * runtime (by using ini_set()), read the PHP documentation: + * http://www.php.net/manual/ini.list.php + * See drupal_environment_initialize() in includes/bootstrap.inc for required + * runtime settings and the .htaccess file for non-runtime settings. Settings + * defined there should not be duplicated here so as to avoid conflict issues. + */ + +/** + * Some distributions of Linux (most notably Debian) ship their PHP + * installations with garbage collection (gc) disabled. Since Drupal depends on + * PHP's garbage collection for clearing sessions, ensure that garbage + * collection occurs by using the most common settings. + */ +ini_set('session.gc_probability', 1); +ini_set('session.gc_divisor', 100); + +/** + * Set session lifetime (in seconds), i.e. the time from the user's last visit + * to the active session may be deleted by the session garbage collector. When + * a session is deleted, authenticated users are logged out, and the contents + * of the user's $_SESSION variable is discarded. + */ +ini_set('session.gc_maxlifetime', 200000); + +/** + * Set session cookie lifetime (in seconds), i.e. the time from the session is + * created to the cookie expires, i.e. when the browser is expected to discard + * the cookie. The value 0 means "until the browser is closed". + */ +ini_set('session.cookie_lifetime', 2000000); + +/** + * If you encounter a situation where users post a large amount of text, and + * the result is stripped out upon viewing but can still be edited, Drupal's + * output filter may not have sufficient memory to process it. If you + * experience this issue, you may wish to uncomment the following two lines + * and increase the limits of these variables. For more information, see + * http://php.net/manual/pcre.configuration.php. + */ +# ini_set('pcre.backtrack_limit', 200000); +# ini_set('pcre.recursion_limit', 200000); + +/** + * Drupal automatically generates a unique session cookie name for each site + * based on its full domain name. If you have multiple domains pointing at the + * same Drupal site, you can either redirect them all to a single domain (see + * comment in .htaccess), or uncomment the line below and specify their shared + * base domain. Doing so assures that users remain logged in as they cross + * between your various domains. Make sure to always start the $cookie_domain + * with a leading dot, as per RFC 2109. + */ +# $cookie_domain = '.example.com'; + +/** + * Variable overrides: + * + * To override specific entries in the 'variable' table for this site, + * set them here. You usually don't need to use this feature. This is + * useful in a configuration file for a vhost or directory, rather than + * the default settings.php. Any configuration setting from the 'variable' + * table can be given a new value. Note that any values you provide in + * these variable overrides will not be modifiable from the Drupal + * administration interface. + * + * The following overrides are examples: + * - site_name: Defines the site's name. + * - theme_default: Defines the default theme for this site. + * - anonymous: Defines the human-readable name of anonymous users. + * Remove the leading hash signs to enable. + */ +# $conf['site_name'] = 'My Drupal site'; +# $conf['theme_default'] = 'garland'; +# $conf['anonymous'] = 'Visitor'; + +/** + * A custom theme can be set for the offline page. This applies when the site + * is explicitly set to maintenance mode through the administration page or when + * the database is inactive due to an error. It can be set through the + * 'maintenance_theme' key. The template file should also be copied into the + * theme. It is located inside 'modules/system/maintenance-page.tpl.php'. + * Note: This setting does not apply to installation and update pages. + */ +# $conf['maintenance_theme'] = 'bartik'; + +/** + * Reverse Proxy Configuration: + * + * Reverse proxy servers are often used to enhance the performance + * of heavily visited sites and may also provide other site caching, + * security, or encryption benefits. In an environment where Drupal + * is behind a reverse proxy, the real IP address of the client should + * be determined such that the correct client IP address is available + * to Drupal's logging, statistics, and access management systems. In + * the most simple scenario, the proxy server will add an + * X-Forwarded-For header to the request that contains the client IP + * address. However, HTTP headers are vulnerable to spoofing, where a + * malicious client could bypass restrictions by setting the + * X-Forwarded-For header directly. Therefore, Drupal's proxy + * configuration requires the IP addresses of all remote proxies to be + * specified in $conf['reverse_proxy_addresses'] to work correctly. + * + * Enable this setting to get Drupal to determine the client IP from + * the X-Forwarded-For header (or $conf['reverse_proxy_header'] if set). + * If you are unsure about this setting, do not have a reverse proxy, + * or Drupal operates in a shared hosting environment, this setting + * should remain commented out. + * + * In order for this setting to be used you must specify every possible + * reverse proxy IP address in $conf['reverse_proxy_addresses']. + * If a complete list of reverse proxies is not available in your + * environment (for example, if you use a CDN) you may set the + * $_SERVER['REMOTE_ADDR'] variable directly in settings.php. + * Be aware, however, that it is likely that this would allow IP + * address spoofing unless more advanced precautions are taken. + */ +# $conf['reverse_proxy'] = TRUE; + +/** + * Specify every reverse proxy IP address in your environment. + * This setting is required if $conf['reverse_proxy'] is TRUE. + */ +# $conf['reverse_proxy_addresses'] = array('a.b.c.d', ...); + +/** + * Set this value if your proxy server sends the client IP in a header + * other than X-Forwarded-For. + */ +# $conf['reverse_proxy_header'] = 'HTTP_X_CLUSTER_CLIENT_IP'; + +/** + * Page caching: + * + * By default, Drupal sends a "Vary: Cookie" HTTP header for anonymous page + * views. This tells a HTTP proxy that it may return a page from its local + * cache without contacting the web server, if the user sends the same Cookie + * header as the user who originally requested the cached page. Without "Vary: + * Cookie", authenticated users would also be served the anonymous page from + * the cache. If the site has mostly anonymous users except a few known + * editors/administrators, the Vary header can be omitted. This allows for + * better caching in HTTP proxies (including reverse proxies), i.e. even if + * clients send different cookies, they still get content served from the cache. + * However, authenticated users should access the site directly (i.e. not use an + * HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid + * getting cached pages from the proxy. + */ +# $conf['omit_vary_cookie'] = TRUE; + +/** + * CSS/JS aggregated file gzip compression: + * + * By default, when CSS or JS aggregation and clean URLs are enabled Drupal will + * store a gzip compressed (.gz) copy of the aggregated files. If this file is + * available then rewrite rules in the default .htaccess file will serve these + * files to browsers that accept gzip encoded content. This allows pages to load + * faster for these users and has minimal impact on server load. If you are + * using a webserver other than Apache httpd, or a caching reverse proxy that is + * configured to cache and compress these files itself you may want to uncomment + * one or both of the below lines, which will prevent gzip files being stored. + */ +# $conf['css_gzip_compression'] = FALSE; +# $conf['js_gzip_compression'] = FALSE; + +/** + * Block caching: + * + * Block caching may not be compatible with node access modules depending on + * how the original block cache policy is defined by the module that provides + * the block. By default, Drupal therefore disables block caching when one or + * more modules implement hook_node_grants(). If you consider block caching to + * be safe on your site and want to bypass this restriction, uncomment the line + * below. + */ +# $conf['block_cache_bypass_node_grants'] = TRUE; + +/** + * String overrides: + * + * To override specific strings on your site with or without enabling the Locale + * module, add an entry to this list. This functionality allows you to change + * a small number of your site's default English language interface strings. + * + * Remove the leading hash signs to enable. + */ +# $conf['locale_custom_strings_en'][''] = array( +# 'forum' => 'Discussion board', +# '@count min' => '@count minutes', +# ); + +/** + * + * IP blocking: + * + * To bypass database queries for denied IP addresses, use this setting. + * Drupal queries the {blocked_ips} table by default on every page request + * for both authenticated and anonymous users. This allows the system to + * block IP addresses from within the administrative interface and before any + * modules are loaded. However on high traffic websites you may want to avoid + * this query, allowing you to bypass database access altogether for anonymous + * users under certain caching configurations. + * + * If using this setting, you will need to add back any IP addresses which + * you may have blocked via the administrative interface. Each element of this + * array represents a blocked IP address. Uncommenting the array and leaving it + * empty will have the effect of disabling IP blocking on your site. + * + * Remove the leading hash signs to enable. + */ +# $conf['blocked_ips'] = array( +# 'a.b.c.d', +# ); + +/** + * Fast 404 pages: + * + * Drupal can generate fully themed 404 pages. However, some of these responses + * are for images or other resource files that are not displayed to the user. + * This can waste bandwidth, and also generate server load. + * + * The options below return a simple, fast 404 page for URLs matching a + * specific pattern: + * - 404_fast_paths_exclude: A regular expression to match paths to exclude, + * such as images generated by image styles, or dynamically-resized images. + * If you need to add more paths, you can add '|path' to the expression. + * - 404_fast_paths: A regular expression to match paths that should return a + * simple 404 page, rather than the fully themed 404 page. If you don't have + * any aliases ending in htm or html you can add '|s?html?' to the expression. + * - 404_fast_html: The html to return for simple 404 pages. + * + * Add leading hash signs if you would like to disable this functionality. + */ +$conf['404_fast_paths_exclude'] = '/\/(?:styles)\//'; +$conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; +$conf['404_fast_html'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; + +/** + * By default the page request process will return a fast 404 page for missing + * files if they match the regular expression set in '404_fast_paths' and not + * '404_fast_paths_exclude' above. 404 errors will simultaneously be logged in + * the Drupal system log. + * + * You can choose to return a fast 404 page earlier for missing pages (as soon + * as settings.php is loaded) by uncommenting the line below. This speeds up + * server response time when loading 404 error pages and prevents the 404 error + * from being logged in the Drupal system log. In order to prevent valid pages + * such as image styles and other generated content that may match the + * '404_fast_paths' regular expression from returning 404 errors, it is + * necessary to add them to the '404_fast_paths_exclude' regular expression + * above. Make sure that you understand the effects of this feature before + * uncommenting the line below. + */ +# drupal_fast_404(); + +/** + * External access proxy settings: + * + * If your site must access the Internet via a web proxy then you can enter + * the proxy settings here. Currently only basic authentication is supported + * by using the username and password variables. The proxy_user_agent variable + * can be set to NULL for proxies that require no User-Agent header or to a + * non-empty string for proxies that limit requests to a specific agent. The + * proxy_exceptions variable is an array of host names to be accessed directly, + * not via proxy. + */ +# $conf['proxy_server'] = ''; +# $conf['proxy_port'] = 8080; +# $conf['proxy_username'] = ''; +# $conf['proxy_password'] = ''; +# $conf['proxy_user_agent'] = ''; +# $conf['proxy_exceptions'] = array('127.0.0.1', 'localhost'); + +/** + * Authorized file system operations: + * + * The Update manager module included with Drupal provides a mechanism for + * site administrators to securely install missing updates for the site + * directly through the web user interface. On securely-configured servers, + * the Update manager will require the administrator to provide SSH or FTP + * credentials before allowing the installation to proceed; this allows the + * site to update the new files as the user who owns all the Drupal files, + * instead of as the user the webserver is running as. On servers where the + * webserver user is itself the owner of the Drupal files, the administrator + * will not be prompted for SSH or FTP credentials (note that these server + * setups are common on shared hosting, but are inherently insecure). + * + * Some sites might wish to disable the above functionality, and only update + * the code directly via SSH or FTP themselves. This setting completely + * disables all functionality related to these authorized file operations. + * + * @see http://drupal.org/node/244924 + * + * Remove the leading hash signs to disable. + */ +# $conf['allow_authorize_operations'] = FALSE; diff --git a/files/.htaccess b/files/.htaccess new file mode 100644 index 0000000..7051eb8 --- /dev/null +++ b/files/.htaccess @@ -0,0 +1,15 @@ +# Turn off all options we don't need. +Options None +Options +FollowSymLinks + +# Set the catch-all handler to prevent scripts from being executed. +SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006 + + # Override the handler again if we're run later in the evaluation list. + SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003 + + +# If we know how to do it safely, disable the PHP engine entirely. + + php_flag engine off + \ No newline at end of file diff --git a/gitignore b/gitignore new file mode 100644 index 0000000..447acd9 --- /dev/null +++ b/gitignore @@ -0,0 +1,23 @@ +/settings.php +files +/*.project +/*.buildpath +/*.settings +.gitignore +dx + +# Ignore paths that contain generated content. +files/ +sites/*/files +sites/*/private + +# Ignore default text files +robots.txt +/CHANGELOG.txt +/COPYRIGHT.txt +/INSTALL*.txt +/LICENSE.txt +/MAINTAINERS.txt +/UPGRADE.txt +/README.txt + diff --git a/modules/school/school.info b/modules/school/school.info new file mode 100644 index 0000000..cae6661 --- /dev/null +++ b/modules/school/school.info @@ -0,0 +1,4 @@ +name = school +description = provides information about school management +core = 7.x +files[]=studentImporter.inc diff --git a/modules/school/school.install b/modules/school/school.install new file mode 100644 index 0000000..fee35cf --- /dev/null +++ b/modules/school/school.install @@ -0,0 +1,116 @@ +'Administrator table', + 'fields' =>array( + 'admin_id'=> array( + 'description' =>'the primary identifier for administrator', + 'type'=>'serial', + 'unsigned'=>TRUE, + 'not null'=>TRUE ), + 'admin_name'=>array( + 'description'=>'admin name', + 'type'=>'varchar', + 'length'=>32, + 'not null'=>TRUE), + + 'admin_email'=>array( + 'description'=>'admin email id', + 'type'=>'varchar', + 'length'=>32, + 'not null'=>TRUE), + ), + 'primary key'=>array('admin_id'), + ); + + + $schema ['sch_student']= array( + 'description '=>'Students table', + 'fields' =>array( + 'student_id'=> array( + 'description' =>'the primary identifier for student', + 'type'=>'serial', + 'unsigned'=>TRUE, + 'not null'=>TRUE ), + 'student_name'=> array( + 'description'=>'student name', + 'type'=>'varchar', + 'length'=>32, + 'not null'=>TRUE), + 'student_email'=> array( + 'description'=>'student email id', + 'type'=>'varchar', + 'length'=>32, + 'not null'=>TRUE), + 'student_dob'=> array( + 'type'=>'int', + 'not null'=>TRUE), + ), + 'primary key'=> array('student_id'), + ); + + $schema ['sch_teacher']= array( + 'description '=>'Teachers table', + 'fields' =>array( + 'teacher_id'=> array( + 'description' =>'the primary identifier for teacher', + 'type'=>'serial', + 'unsigned'=>TRUE, + 'not null'=>TRUE ), + 'teacher_name'=>array( + 'description'=>'teacher name', + 'type'=>'varchar', + 'length'=>32, + 'not null'=>TRUE), + 'teacher_email'=>array( + 'description'=>'teacher email id', + 'type'=>'varchar', + 'length'=>32, + 'not null'=>TRUE), + 'teacher_dob'=>array( + 'description'=>'teacher DOB', + 'type'=>'int', + 'not null'=>TRUE), + ), + 'primary key'=>array('teacher_id'), + ); + $schema ['sch_subject']= array( + 'description '=>'Subjects table', + 'fields' =>array( + 'subject_id'=> array( + 'description' =>'the primary identifier for subject', + 'type'=>'serial', + 'unsigned'=>TRUE, + 'not null'=>TRUE ), + 'subject_name'=>array( + 'description'=>'subject name', + 'type'=>'varchar', + 'length'=>32, + 'not null'=>TRUE), + ), + 'primary key'=>array('subject_id'), + ); + $schema ['sch_class']= array( + 'description '=>'Class table', + 'fields' =>array( + 'class_id'=> array( + 'description' =>'the primary identifier for class', + 'type'=>'serial', + 'unsigned'=>TRUE, + 'not null'=>TRUE ), + 'class_name'=>array( + 'description'=>'class name', + 'type'=>'varchar', + 'length'=>32, + 'not null'=>TRUE), + ), + + 'primary key'=>array('class_id'), + ); + + + return $schema; +} \ No newline at end of file diff --git a/modules/school/school.module b/modules/school/school.module new file mode 100644 index 0000000..3ecbf52 --- /dev/null +++ b/modules/school/school.module @@ -0,0 +1,54 @@ + 'Upload A File', + 'type'=> MENU_NORMAL_ITEM, + 'description'=>'Import a csv file', + 'page callback'=>'drupal_get_form', + 'page arguments'=>array('school_import_form'), + 'access callback'=>TRUE, + ); + return $items; + +} +function school_import_form($form,&$form_state){ + $form['notes'] = array( + '#type' => 'markup', + '#markup' => '
A few notes when uploading.
  • Make sure the file is in a .csv format.
  • Columns should be in *this* order
  • Be sure to click the "Upload" button when you select a csv.
', + // '#upload_location' => 'public://tmp/', + ); + $form ['import']= array( + '#title'=>t('Import'), + '#type'=>'managed_file', + '#description'=>t('The uploaded csv file is imported here'), + //'#upload_location'=>'public://tmp/', + '#upload_validators'=> array( + 'file_validate_extensions' =>array('csv'), + ), + + ); + $form['submit'] = array ( + '#type' => 'submit', + '#value' => t('Import'), + ); + return $form; +} +function school_import_form_submit($form,$form_state){ + +} +function school_import_batchprocessing(){ + +} \ No newline at end of file diff --git a/modules/school/studentImporter.inc b/modules/school/studentImporter.inc new file mode 100644 index 0000000..3edcf2e --- /dev/null +++ b/modules/school/studentImporter.inc @@ -0,0 +1,40 @@ + 'Upload A File', + 'type'=> NORMAL_MENU_ITEM, + 'description'=>'Import a csv file', + 'page callback'=>'drupal_get_form', + 'page arguments'=>array('school_import_form'), + ); + return $items; + +} +function school_import_form($form,&$form_state){ + $form['notes'] = array( + '#type' => 'markup', + '#markup' => '
A few notes when uploading.
  • Make sure the file is in a .csv format.
  • Columns should be in *this* order
  • Be sure to click the "Upload" button when you select a csv.
', + '#upload_location' => 'public://tmp/', + ); + $form ['import']= array( + '#title'=>t('Importer'), + '#type'=>'managed_file', + '#description'=>t('The uploaded csv file is imported here'), + '#upload_location'=>'public://tmp/', + '#upload_validators'=> array( + file_validate_extensions =>array('csv'), + ), + + ); + $form['submit'] = array ( + '#type' => 'submit', + '#value' => t('Importer'), + ); + return $form; +} +function school_import_form_submit($form,$form_state){ + +} +function school_import_batchprocessing(){ + +} \ No newline at end of file diff --git a/reversestring.php b/reversestring.php deleted file mode 100644 index a95b5c0..0000000 --- a/reversestring.php +++ /dev/null @@ -1,12 +0,0 @@ --1;$i--){ - $rev_str.= $str{$i}; - } - return $rev_str; -} -$str ="my string"; -echo stringRev($str); -?> \ No newline at end of file diff --git a/sample3.php b/sample3.php deleted file mode 100644 index 2cc0c26..0000000 --- a/sample3.php +++ /dev/null @@ -1,6 +0,0 @@ -"11","pia"=>"12","ram"=>"13"); -print_r(array_change_key_case($namelist,CASE_UPPER)); -print_r(array_chunk($namelist,2)); -?> \ No newline at end of file diff --git a/settings.php b/settings.php new file mode 100644 index 0000000..c35940c --- /dev/null +++ b/settings.php @@ -0,0 +1,581 @@ + 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'port' => 3306, + * 'prefix' => 'myprefix_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * The "driver" property indicates what Drupal database driver the + * connection should use. This is usually the same as the name of the + * database type, such as mysql or sqlite, but not always. The other + * properties will vary depending on the driver. For SQLite, you must + * specify a database file name in a directory that is writable by the + * webserver. For most other drivers, you must specify a + * username, password, host, and database name. + * + * Transaction support is enabled by default for all drivers that support it, + * including MySQL. To explicitly disable it, set the 'transactions' key to + * FALSE. + * Note that some configurations of MySQL, such as the MyISAM engine, don't + * support it and will proceed silently even if enabled. If you experience + * transaction related crashes with such configuration, set the 'transactions' + * key to FALSE. + * + * For each database, you may optionally specify multiple "target" databases. + * A target database allows Drupal to try to send certain queries to a + * different database if it can but fall back to the default connection if not. + * That is useful for master/slave replication, as Drupal may try to connect + * to a slave server when appropriate and if one is not available will simply + * fall back to the single master server. + * + * The general format for the $databases array is as follows: + * @code + * $databases['default']['default'] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['extra']['default'] = $info_array; + * @endcode + * + * In the above example, $info_array is an array of settings described above. + * The first line sets a "default" database that has one master database + * (the second level default). The second and third lines create an array + * of potential slave databases. Drupal will select one at random for a given + * request as needed. The fourth line creates a new database with a name of + * "extra". + * + * For a single database configuration, the following is sufficient: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => 'main_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * You can optionally set prefixes for some or all database table names + * by using the 'prefix' setting. If a prefix is specified, the table + * name will be prepended with its value. Be sure to use valid database + * characters only, usually alphanumeric and underscore. If no prefixes + * are desired, leave it as an empty string ''. + * + * To have all database names prefixed, set 'prefix' as a string: + * @code + * 'prefix' => 'main_', + * @endcode + * To provide prefixes for specific tables, set 'prefix' as an array. + * The array's keys are the table names and the values are the prefixes. + * The 'default' element is mandatory and holds the prefix for any tables + * not specified elsewhere in the array. Example: + * @code + * 'prefix' => array( + * 'default' => 'main_', + * 'users' => 'shared_', + * 'sessions' => 'shared_', + * 'role' => 'shared_', + * 'authmap' => 'shared_', + * ), + * @endcode + * You can also use a reference to a schema/database as a prefix. This may be + * useful if your Drupal installation exists in a schema that is not the default + * or you want to access several databases from the same code base at the same + * time. + * Example: + * @code + * 'prefix' => array( + * 'default' => 'main.', + * 'users' => 'shared.', + * 'sessions' => 'shared.', + * 'role' => 'shared.', + * 'authmap' => 'shared.', + * ); + * @endcode + * NOTE: MySQL and SQLite's definition of a schema is a database. + * + * Advanced users can add or override initial commands to execute when + * connecting to the database server, as well as PDO connection settings. For + * example, to enable MySQL SELECT queries to exceed the max_join_size system + * variable, and to reduce the database connection timeout to 5 seconds: + * + * @code + * $databases['default']['default'] = array( + * 'init_commands' => array( + * 'big_selects' => 'SET SQL_BIG_SELECTS=1', + * ), + * 'pdo' => array( + * PDO::ATTR_TIMEOUT => 5, + * ), + * ); + * @endcode + * + * WARNING: These defaults are designed for database portability. Changing them + * may cause unexpected behavior, including potential data loss. + * + * @see DatabaseConnection_mysql::__construct + * @see DatabaseConnection_pgsql::__construct + * @see DatabaseConnection_sqlite::__construct + * + * Database configuration format: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'pgsql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'sqlite', + * 'database' => '/path/to/databasefilename', + * ); + * @endcode + */ +$databases = array ( + 'default' => + array ( + 'default' => + array ( + 'database' => 'schooldb', + 'username' => 'root', + 'password' => '', + 'host' => 'localhost', + 'port' => '', + 'driver' => 'mysql', + 'prefix' => '', + ), + ), +); + +/** + * Access control for update.php script. + * + * If you are updating your Drupal installation using the update.php script but + * are not logged in using either an account with the "Administer software + * updates" permission or the site maintenance account (the account that was + * created during installation), you will need to modify the access check + * statement below. Change the FALSE to a TRUE to disable the access check. + * After finishing the upgrade, be sure to open this file again and change the + * TRUE back to a FALSE! + */ +$update_free_access = FALSE; + +/** + * Salt for one-time login links and cancel links, form tokens, etc. + * + * This variable will be set to a random value by the installer. All one-time + * login links will be invalidated if the value is changed. Note that if your + * site is deployed on a cluster of web servers, you must ensure that this + * variable has the same value on each server. If this variable is empty, a hash + * of the serialized database credentials will be used as a fallback salt. + * + * For enhanced security, you may set this variable to a value using the + * contents of a file outside your docroot that is never saved together + * with any backups of your Drupal files and database. + * + * Example: + * $drupal_hash_salt = file_get_contents('/home/example/salt.txt'); + * + */ +$drupal_hash_salt = '4GKp4p7pwhM7QqUoFSSuzQTbdvT8QPo7Q9UsHIGLLYk'; + +/** + * Base URL (optional). + * + * If Drupal is generating incorrect URLs on your site, which could + * be in HTML headers (links to CSS and JS files) or visible links on pages + * (such as in menus), uncomment the Base URL statement below (remove the + * leading hash sign) and fill in the absolute URL to your Drupal installation. + * + * You might also want to force users to use a given domain. + * See the .htaccess file for more information. + * + * Examples: + * $base_url = 'http://www.example.com'; + * $base_url = 'http://www.example.com:8888'; + * $base_url = 'http://www.example.com/drupal'; + * $base_url = 'https://www.example.com:8888/drupal'; + * + * It is not allowed to have a trailing slash; Drupal will add it + * for you. + */ +# $base_url = 'http://www.example.com'; // NO trailing slash! + +/** + * PHP settings: + * + * To see what PHP settings are possible, including whether they can be set at + * runtime (by using ini_set()), read the PHP documentation: + * http://www.php.net/manual/ini.list.php + * See drupal_environment_initialize() in includes/bootstrap.inc for required + * runtime settings and the .htaccess file for non-runtime settings. Settings + * defined there should not be duplicated here so as to avoid conflict issues. + */ + +/** + * Some distributions of Linux (most notably Debian) ship their PHP + * installations with garbage collection (gc) disabled. Since Drupal depends on + * PHP's garbage collection for clearing sessions, ensure that garbage + * collection occurs by using the most common settings. + */ +ini_set('session.gc_probability', 1); +ini_set('session.gc_divisor', 100); + +/** + * Set session lifetime (in seconds), i.e. the time from the user's last visit + * to the active session may be deleted by the session garbage collector. When + * a session is deleted, authenticated users are logged out, and the contents + * of the user's $_SESSION variable is discarded. + */ +ini_set('session.gc_maxlifetime', 200000); + +/** + * Set session cookie lifetime (in seconds), i.e. the time from the session is + * created to the cookie expires, i.e. when the browser is expected to discard + * the cookie. The value 0 means "until the browser is closed". + */ +ini_set('session.cookie_lifetime', 2000000); + +/** + * If you encounter a situation where users post a large amount of text, and + * the result is stripped out upon viewing but can still be edited, Drupal's + * output filter may not have sufficient memory to process it. If you + * experience this issue, you may wish to uncomment the following two lines + * and increase the limits of these variables. For more information, see + * http://php.net/manual/pcre.configuration.php. + */ +# ini_set('pcre.backtrack_limit', 200000); +# ini_set('pcre.recursion_limit', 200000); + +/** + * Drupal automatically generates a unique session cookie name for each site + * based on its full domain name. If you have multiple domains pointing at the + * same Drupal site, you can either redirect them all to a single domain (see + * comment in .htaccess), or uncomment the line below and specify their shared + * base domain. Doing so assures that users remain logged in as they cross + * between your various domains. Make sure to always start the $cookie_domain + * with a leading dot, as per RFC 2109. + */ +# $cookie_domain = '.example.com'; + +/** + * Variable overrides: + * + * To override specific entries in the 'variable' table for this site, + * set them here. You usually don't need to use this feature. This is + * useful in a configuration file for a vhost or directory, rather than + * the default settings.php. Any configuration setting from the 'variable' + * table can be given a new value. Note that any values you provide in + * these variable overrides will not be modifiable from the Drupal + * administration interface. + * + * The following overrides are examples: + * - site_name: Defines the site's name. + * - theme_default: Defines the default theme for this site. + * - anonymous: Defines the human-readable name of anonymous users. + * Remove the leading hash signs to enable. + */ +# $conf['site_name'] = 'My Drupal site'; +# $conf['theme_default'] = 'garland'; +# $conf['anonymous'] = 'Visitor'; + +/** + * A custom theme can be set for the offline page. This applies when the site + * is explicitly set to maintenance mode through the administration page or when + * the database is inactive due to an error. It can be set through the + * 'maintenance_theme' key. The template file should also be copied into the + * theme. It is located inside 'modules/system/maintenance-page.tpl.php'. + * Note: This setting does not apply to installation and update pages. + */ +# $conf['maintenance_theme'] = 'bartik'; + +/** + * Reverse Proxy Configuration: + * + * Reverse proxy servers are often used to enhance the performance + * of heavily visited sites and may also provide other site caching, + * security, or encryption benefits. In an environment where Drupal + * is behind a reverse proxy, the real IP address of the client should + * be determined such that the correct client IP address is available + * to Drupal's logging, statistics, and access management systems. In + * the most simple scenario, the proxy server will add an + * X-Forwarded-For header to the request that contains the client IP + * address. However, HTTP headers are vulnerable to spoofing, where a + * malicious client could bypass restrictions by setting the + * X-Forwarded-For header directly. Therefore, Drupal's proxy + * configuration requires the IP addresses of all remote proxies to be + * specified in $conf['reverse_proxy_addresses'] to work correctly. + * + * Enable this setting to get Drupal to determine the client IP from + * the X-Forwarded-For header (or $conf['reverse_proxy_header'] if set). + * If you are unsure about this setting, do not have a reverse proxy, + * or Drupal operates in a shared hosting environment, this setting + * should remain commented out. + * + * In order for this setting to be used you must specify every possible + * reverse proxy IP address in $conf['reverse_proxy_addresses']. + * If a complete list of reverse proxies is not available in your + * environment (for example, if you use a CDN) you may set the + * $_SERVER['REMOTE_ADDR'] variable directly in settings.php. + * Be aware, however, that it is likely that this would allow IP + * address spoofing unless more advanced precautions are taken. + */ +# $conf['reverse_proxy'] = TRUE; + +/** + * Specify every reverse proxy IP address in your environment. + * This setting is required if $conf['reverse_proxy'] is TRUE. + */ +# $conf['reverse_proxy_addresses'] = array('a.b.c.d', ...); + +/** + * Set this value if your proxy server sends the client IP in a header + * other than X-Forwarded-For. + */ +# $conf['reverse_proxy_header'] = 'HTTP_X_CLUSTER_CLIENT_IP'; + +/** + * Page caching: + * + * By default, Drupal sends a "Vary: Cookie" HTTP header for anonymous page + * views. This tells a HTTP proxy that it may return a page from its local + * cache without contacting the web server, if the user sends the same Cookie + * header as the user who originally requested the cached page. Without "Vary: + * Cookie", authenticated users would also be served the anonymous page from + * the cache. If the site has mostly anonymous users except a few known + * editors/administrators, the Vary header can be omitted. This allows for + * better caching in HTTP proxies (including reverse proxies), i.e. even if + * clients send different cookies, they still get content served from the cache. + * However, authenticated users should access the site directly (i.e. not use an + * HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid + * getting cached pages from the proxy. + */ +# $conf['omit_vary_cookie'] = TRUE; + +/** + * CSS/JS aggregated file gzip compression: + * + * By default, when CSS or JS aggregation and clean URLs are enabled Drupal will + * store a gzip compressed (.gz) copy of the aggregated files. If this file is + * available then rewrite rules in the default .htaccess file will serve these + * files to browsers that accept gzip encoded content. This allows pages to load + * faster for these users and has minimal impact on server load. If you are + * using a webserver other than Apache httpd, or a caching reverse proxy that is + * configured to cache and compress these files itself you may want to uncomment + * one or both of the below lines, which will prevent gzip files being stored. + */ +# $conf['css_gzip_compression'] = FALSE; +# $conf['js_gzip_compression'] = FALSE; + +/** + * Block caching: + * + * Block caching may not be compatible with node access modules depending on + * how the original block cache policy is defined by the module that provides + * the block. By default, Drupal therefore disables block caching when one or + * more modules implement hook_node_grants(). If you consider block caching to + * be safe on your site and want to bypass this restriction, uncomment the line + * below. + */ +# $conf['block_cache_bypass_node_grants'] = TRUE; + +/** + * String overrides: + * + * To override specific strings on your site with or without enabling the Locale + * module, add an entry to this list. This functionality allows you to change + * a small number of your site's default English language interface strings. + * + * Remove the leading hash signs to enable. + */ +# $conf['locale_custom_strings_en'][''] = array( +# 'forum' => 'Discussion board', +# '@count min' => '@count minutes', +# ); + +/** + * + * IP blocking: + * + * To bypass database queries for denied IP addresses, use this setting. + * Drupal queries the {blocked_ips} table by default on every page request + * for both authenticated and anonymous users. This allows the system to + * block IP addresses from within the administrative interface and before any + * modules are loaded. However on high traffic websites you may want to avoid + * this query, allowing you to bypass database access altogether for anonymous + * users under certain caching configurations. + * + * If using this setting, you will need to add back any IP addresses which + * you may have blocked via the administrative interface. Each element of this + * array represents a blocked IP address. Uncommenting the array and leaving it + * empty will have the effect of disabling IP blocking on your site. + * + * Remove the leading hash signs to enable. + */ +# $conf['blocked_ips'] = array( +# 'a.b.c.d', +# ); + +/** + * Fast 404 pages: + * + * Drupal can generate fully themed 404 pages. However, some of these responses + * are for images or other resource files that are not displayed to the user. + * This can waste bandwidth, and also generate server load. + * + * The options below return a simple, fast 404 page for URLs matching a + * specific pattern: + * - 404_fast_paths_exclude: A regular expression to match paths to exclude, + * such as images generated by image styles, or dynamically-resized images. + * If you need to add more paths, you can add '|path' to the expression. + * - 404_fast_paths: A regular expression to match paths that should return a + * simple 404 page, rather than the fully themed 404 page. If you don't have + * any aliases ending in htm or html you can add '|s?html?' to the expression. + * - 404_fast_html: The html to return for simple 404 pages. + * + * Add leading hash signs if you would like to disable this functionality. + */ +$conf['404_fast_paths_exclude'] = '/\/(?:styles)\//'; +$conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; +$conf['404_fast_html'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; + +/** + * By default the page request process will return a fast 404 page for missing + * files if they match the regular expression set in '404_fast_paths' and not + * '404_fast_paths_exclude' above. 404 errors will simultaneously be logged in + * the Drupal system log. + * + * You can choose to return a fast 404 page earlier for missing pages (as soon + * as settings.php is loaded) by uncommenting the line below. This speeds up + * server response time when loading 404 error pages and prevents the 404 error + * from being logged in the Drupal system log. In order to prevent valid pages + * such as image styles and other generated content that may match the + * '404_fast_paths' regular expression from returning 404 errors, it is + * necessary to add them to the '404_fast_paths_exclude' regular expression + * above. Make sure that you understand the effects of this feature before + * uncommenting the line below. + */ +# drupal_fast_404(); + +/** + * External access proxy settings: + * + * If your site must access the Internet via a web proxy then you can enter + * the proxy settings here. Currently only basic authentication is supported + * by using the username and password variables. The proxy_user_agent variable + * can be set to NULL for proxies that require no User-Agent header or to a + * non-empty string for proxies that limit requests to a specific agent. The + * proxy_exceptions variable is an array of host names to be accessed directly, + * not via proxy. + */ +# $conf['proxy_server'] = ''; +# $conf['proxy_port'] = 8080; +# $conf['proxy_username'] = ''; +# $conf['proxy_password'] = ''; +# $conf['proxy_user_agent'] = ''; +# $conf['proxy_exceptions'] = array('127.0.0.1', 'localhost'); + +/** + * Authorized file system operations: + * + * The Update manager module included with Drupal provides a mechanism for + * site administrators to securely install missing updates for the site + * directly through the web user interface. On securely-configured servers, + * the Update manager will require the administrator to provide SSH or FTP + * credentials before allowing the installation to proceed; this allows the + * site to update the new files as the user who owns all the Drupal files, + * instead of as the user the webserver is running as. On servers where the + * webserver user is itself the owner of the Drupal files, the administrator + * will not be prompted for SSH or FTP credentials (note that these server + * setups are common on shared hosting, but are inherently insecure). + * + * Some sites might wish to disable the above functionality, and only update + * the code directly via SSH or FTP themselves. This setting completely + * disables all functionality related to these authorized file operations. + * + * @see http://drupal.org/node/244924 + * + * Remove the leading hash signs to disable. + */ +# $conf['allow_authorize_operations'] = FALSE; diff --git a/test.txt b/test.txt deleted file mode 100644 index 1ce4ff8..0000000 --- a/test.txt +++ /dev/null @@ -1,21 +0,0 @@ -hello my name is naveen - -helo my name is Ramji - -Hi.. What the heck. -hello ma name a Deepesh -bjcjdkff - - -kksdfksdkfkdn -nvknvndf -hbcxnvmv4 - -'vkdfnkgnkdfg -gkdfn,v -kgnf,gmf -gknbfkcnbm -mfbncvmb -'nfgbnfgmb -kbnfgmb - diff --git a/test2.txt b/test2.txt deleted file mode 100644 index 77e7990..0000000 --- a/test2.txt +++ /dev/null @@ -1,6 +0,0 @@ - - -Hello Thomson - - -Did you brought the gift? From 181f87e5c697e35fcd845c62eb5569e3ad9ea16d Mon Sep 17 00:00:00 2001 From: prameela Date: Fri, 5 May 2017 15:03:28 +0530 Subject: [PATCH 3/4] FormsAndTables --- modules/school/school.info | 4 +- modules/school/school.install | 251 ++++++++++-------- modules/school/school.module | 457 +++++++++++++++++++++++++++++++- modules/school/school.views.inc | 167 ++++++++++++ 4 files changed, 761 insertions(+), 118 deletions(-) create mode 100644 modules/school/school.views.inc diff --git a/modules/school/school.info b/modules/school/school.info index cae6661..6e0efdd 100644 --- a/modules/school/school.info +++ b/modules/school/school.info @@ -1,4 +1,6 @@ name = school description = provides information about school management core = 7.x -files[]=studentImporter.inc + + +files[]=school.views.inc diff --git a/modules/school/school.install b/modules/school/school.install index fee35cf..0ea77da 100644 --- a/modules/school/school.install +++ b/modules/school/school.install @@ -1,116 +1,141 @@ 'Administrator table', - 'fields' =>array( - 'admin_id'=> array( - 'description' =>'the primary identifier for administrator', - 'type'=>'serial', - 'unsigned'=>TRUE, - 'not null'=>TRUE ), - 'admin_name'=>array( - 'description'=>'admin name', - 'type'=>'varchar', - 'length'=>32, - 'not null'=>TRUE), - - 'admin_email'=>array( - 'description'=>'admin email id', - 'type'=>'varchar', - 'length'=>32, - 'not null'=>TRUE), - ), - 'primary key'=>array('admin_id'), - ); - - - $schema ['sch_student']= array( - 'description '=>'Students table', - 'fields' =>array( - 'student_id'=> array( - 'description' =>'the primary identifier for student', - 'type'=>'serial', - 'unsigned'=>TRUE, - 'not null'=>TRUE ), - 'student_name'=> array( - 'description'=>'student name', - 'type'=>'varchar', - 'length'=>32, - 'not null'=>TRUE), - 'student_email'=> array( - 'description'=>'student email id', - 'type'=>'varchar', - 'length'=>32, - 'not null'=>TRUE), - 'student_dob'=> array( - 'type'=>'int', - 'not null'=>TRUE), - ), - 'primary key'=> array('student_id'), - ); - - $schema ['sch_teacher']= array( - 'description '=>'Teachers table', - 'fields' =>array( - 'teacher_id'=> array( - 'description' =>'the primary identifier for teacher', - 'type'=>'serial', - 'unsigned'=>TRUE, - 'not null'=>TRUE ), - 'teacher_name'=>array( - 'description'=>'teacher name', - 'type'=>'varchar', - 'length'=>32, - 'not null'=>TRUE), - 'teacher_email'=>array( - 'description'=>'teacher email id', - 'type'=>'varchar', - 'length'=>32, - 'not null'=>TRUE), - 'teacher_dob'=>array( - 'description'=>'teacher DOB', - 'type'=>'int', - 'not null'=>TRUE), - ), - 'primary key'=>array('teacher_id'), - ); - $schema ['sch_subject']= array( - 'description '=>'Subjects table', - 'fields' =>array( - 'subject_id'=> array( - 'description' =>'the primary identifier for subject', - 'type'=>'serial', - 'unsigned'=>TRUE, - 'not null'=>TRUE ), - 'subject_name'=>array( - 'description'=>'subject name', - 'type'=>'varchar', - 'length'=>32, - 'not null'=>TRUE), - ), - 'primary key'=>array('subject_id'), - ); - $schema ['sch_class']= array( - 'description '=>'Class table', - 'fields' =>array( - 'class_id'=> array( - 'description' =>'the primary identifier for class', - 'type'=>'serial', - 'unsigned'=>TRUE, - 'not null'=>TRUE ), - 'class_name'=>array( - 'description'=>'class name', - 'type'=>'varchar', - 'length'=>32, - 'not null'=>TRUE), - ), - - 'primary key'=>array('class_id'), - ); - - - return $schema; -} \ No newline at end of file +function school_schema() { + $schema ['sch_administrator'] = array( + 'description ' => 'Administrator table', + 'fields' => array( + 'admin_id' => array( + 'description' => 'the primary identifier for administrator', + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE), + 'admin_name' => array( + 'description' => 'admin name', + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE), + 'admin_email' => array( + 'description' => 'admin email id', + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE), + ), + 'primary key' => array('admin_id'), + ); + + + $schema ['sch_student'] = array( + 'description ' => 'Students table', + 'fields' => array( + 'student_id' => array( + 'description' => 'the primary identifier for student', + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE), + 'student_name' => array( + 'description' => 'student name', + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE), + 'student_email' => array( + 'description' => 'student email id', + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE), + 'student_dob' => array( + 'type' => 'int', + 'not null' => TRUE), + ), + 'primary key' => array('student_id'), + ); + + $schema ['sch_teacher'] = array( + 'description ' => 'Teachers table', + 'fields' => array( + 'teacher_id' => array( + 'description' => 'the primary identifier for teacher', + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE), + 'teacher_name' => array( + 'description' => 'teacher name', + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE), + 'teacher_email' => array( + 'description' => 'teacher email id', + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE), + 'teacher_dob' => array( + 'description' => 'teacher DOB', + 'type' => 'int', + 'not null' => TRUE), + ), + 'primary key' => array('teacher_id'), + ); + $schema ['sch_subject'] = array( + 'description ' => 'Subjects table', + 'fields' => array( + 'subject_id' => array( + 'description' => 'the primary identifier for subject', + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE), + 'subject_name' => array( + 'description' => 'subject name', + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE), + ), + 'primary key' => array('subject_id'), + ); + $schema ['sch_class'] = array( + 'description ' => 'Class table', + 'fields' => array( + 'class_id' => array( + 'description' => 'the primary identifier for class', + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE), + 'class_name' => array( + 'description' => 'class name', + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE), + ), + 'primary key' => array('class_id'), + ); + + + return $schema; +} +function school_update_1(){ + $table ='sch_student'; + db_add_field($table,'class_id',array( + 'description' => 'the primary identifier for class', + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE) + ); +} +function school_update_2(){ + $table ='sch_subject'; + db_add_field($table,'subject_id',array( + 'description' => 'the primary identifier for subject', + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE) + ); +} +function school_update_3(){ + $table ='sch_class'; + db_add_field($table,'teacher_id',array( + 'description' => 'the primary identifier for class', + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE) + ); +} diff --git a/modules/school/school.module b/modules/school/school.module index 3ecbf52..6aaee5b 100644 --- a/modules/school/school.module +++ b/modules/school/school.module @@ -4,7 +4,39 @@ * school module * */ +/* + * permission + */ +define('CONST_PERM_TEACHER_ADD_Subject','School Teacher add sujects'); +define('CONST_PERM_ADMIN_ADD_TEACHER','School Admin add Teacher'); +define('CONST_PERM_TEACHER_ADD_CLASS','School Teacher add class'); +define('CONST_PERM_ADMIN_ADD_STUDENT','School Admin add student'); +define('CONST_PERM_VIEW_STUDENT','School student view'); +define('CONST_PERM_VIEW_TEACHER','School teacher view'); +define('CONST_PERM_SCHOOL_ADMIN','Access school admin menu'); +define('CONST_PERM_CLASS_SUBJECT_VIEW','Access Class Subject view'); +function school_permission(){ + $permission = array( + CONST_PERM_SCHOOL_ADMIN =>array('title'=>t('Access school admin menu')), + CONST_PERM_VIEW_TEACHER=>array('title'=>t('School teacher view')), + CONST_PERM_VIEW_STUDENT=>array('title'=>t('School student view')), + CONST_PERM_ADMIN_ADD_STUDENT=>array('title'=>t('School Admin add student')), + CONST_PERM_TEACHER_ADD_CLASS=>array('title'=>t('School Teacher add class')), + CONST_PERM_ADMIN_ADD_TEACHER=>array('title'=>t('School Admin add teacher')), + CONST_PERM_TEACHER_ADD_Subject=>array('title'=>t('School Teacher add sujects')), + CONST_PERM_CLASS_SUBJECT_VIEW=>array('title'=>t('Access Class Subject view')), + ); + $result =db_select('role','r') + ->fields('r',array('name')) + ->execute(); + foreach($result as $row){ + $permission['school role permission'.$row->name] = array( + 'title'=>t('has %role role',array( + '%role'=>$row->name))); + } + return $permission; +} function school_help($path,$arg){ switch($path){ case "admin/help#school"; @@ -13,6 +45,7 @@ function school_help($path,$arg){ } } function school_menu(){ + //add file uploader $items ['file-uploader'] = array( 'title'=> 'Upload A File', 'type'=> MENU_NORMAL_ITEM, @@ -21,8 +54,79 @@ function school_menu(){ 'page arguments'=>array('school_import_form'), 'access callback'=>TRUE, ); - return $items; + //Add student form + $items ['add-student'] = array( + 'title'=> 'Student form', + 'type'=> MENU_NORMAL_ITEM, + 'description'=>'basic details of students', + 'page callback'=>'drupal_get_form', + 'page arguments'=>array('school_student_form'), + 'access arguments'=>array(CONST_PERM_ADMIN_ADD_STUDENT), + 'access callback'=>TRUE, + ); + //Edit student form + $items ['editstudent/%/edit']=array( + 'title'=> 'Edit Student', + 'type'=> MENU_CALLBACK, + 'description'=>'edit details of students', + 'page callback'=>'drupal_get_form', + 'page arguments'=>array('edit_student_form',1), + 'access callback'=>'user_access', + + + ); + //View students stored + $items ['students_list page']=array( + 'title'=> 'View Student List', + 'type'=> MENU_NORMAL_ITEM, + 'description'=>'view details of students', + 'page callback'=>'student_view_list', + 'access callback'=>'user_access', + 'access arguments'=>array('access student content'), + ); + //single student view + $items['studentview_page/%']=array( + 'title'=>'single student view', + 'description'=>'single student view', + 'page callback' => 'studentview_page', + 'page arguments' => array(1), + 'access callback'=>'user_access', + 'access arguments' => array('access student content'), + 'type' => MENU_NORMAL_ITEM, + ); + + //add teacher form + $items ['add-teacher'] = array( + 'title'=> 'Teacher form', + 'type'=> MENU_NORMAL_ITEM, + 'description'=>'basic details of teacher', + 'page callback'=>'drupal_get_form', + 'page arguments'=>array('school_teacher_form'), + 'access arguments' => array('access school content'), + 'access callback'=>TRUE, + ); + //add subject form + $items ['add-subject'] = array( + 'title'=> 'Subject form', + 'type'=> MENU_NORMAL_ITEM, + 'description'=>'basic details of subject', + 'page callback'=>'drupal_get_form', + 'page arguments'=>array('school_subject_form'), + 'access arguments' => array('access school content'), + 'access callback'=>TRUE, + ); + //add class form + $items ['add-class'] = array( + 'title'=> 'Class form', + 'type'=> MENU_NORMAL_ITEM, + 'description'=>'basic details of class', + 'page callback'=>'drupal_get_form', + 'page arguments'=>array('school_class_form'), + 'access arguments' => array('access school content'), + 'access callback'=>TRUE, + ); + return $items; } function school_import_form($form,&$form_state){ $form['notes'] = array( @@ -46,9 +150,354 @@ function school_import_form($form,&$form_state){ ); return $form; } -function school_import_form_submit($form,$form_state){ + /* + * Get student form + */ + function school_student_form($form,$form_state){ + $form['student_name'] =array( + '#title' =>t('student_name'), + '#type' => 'textfield', + '#required' => TRUE, + ); + + $form['student_email']=array( + '#title' =>t('student_email'), + '#type' => 'textfield', + '#required' => TRUE, + ); + $form['student_dob']=array( + '#title' =>t('student_dob'), + '#type' => 'textfield', + '#required' => TRUE, + ); + $form['submit']=array( + '#value' => 'submit', + '#type'=> 'submit', + ); + return $form; } -function school_import_batchprocessing(){ +/* + * Store student in database + */ + function school_student_form_submit($form,&$form_state) { + $sql_query =db_insert('sch_student') + ->fields(array( + 'student_name' => $form_state['values']['student_name'], + 'student_email' =>$form_state['values']['student_email'], + 'student_dob'=>$form_state['values']['student_dob'], + + ) + ) + ->execute(); + drupal_set_message("deatils saved"); + drupal_goto('students_list page'); + } + /* + * View student list + */ + function student_view_list(){ + $sql_select= db_select('sch_student','students') + ->fields('students',array('student_id','student_name','student_email','student_dob')) + ->execute(); + $header= array('student_id','student_name','student_email','student_dob','action'); + $rows = array(); + while($data=$sql_select->fetchObject()){ + $rows[]=array( + l($data->student_id,'studentview_page/'.$data->student_id), + $data ->student_name, + $data->student_email, + $data->student_dob, + l('action',"editstudent/$data->student_id/edit"), + ); + } + $output = theme_table( + array( + "header" => $header, + "rows" => $rows, + "attributes" => array(), + "sticky" => true, // Table header will be sticky + "caption" => "", + "colgroups" => array(), + "empty" => t("Table has no data!") // The message to be displayed if table is empty + ) + ); + return $output; + } + /* + * Single student view + */ + function studentview_page($student_id){ + $output = drupal_get_form('school_student_form'); + $sql_select1 = db_select('sch_student','students') + ->fields('students',array('student_id','student_name','student_email','student_dob')) + ->condition('student_id',$student_id,'=') + ->execute(); + $header= array('student_id','student_name','student_email','student_dob'); + $rows = array(); + while($data=$sql_select1->fetchObject()){ + $rows[]=array( + $data->student_id, + $data ->student_name, + $data->student_email, + $data->student_dob, + ); + } + $output = theme_table( + array( + "header" => $header, + "rows" => $rows, + "attributes" => array(), + "sticky" => true, + "caption" => "", + "colgroups" => array(), + "empty" => t("Table has no data!") + ) + ); + return $output; + + } + /* + * Edit student details + */ + function edit_student_form($form,$form_state,$student_id){ + $sql_select = db_select('sch_student','students') + ->fields('students',array('student_name','student_email','student_dob')) + ->condition('student_id',$student_id,'=') + ->execute() + ->fetchObject(); + + $form['student_id'] = array( + '#type' => 'hidden', + '#value' => $student_id, + ); + $form['student_name']= array( + '#type'=>'textfield', + '#title'=>t('student_name'), + '#default_value'=>$sql_select->student_name, + ); + $form['student_email']= array( + '#type'=>'textfield', + '#title'=>t('student_email'), + '#default_value'=>$sql_select->student_email, + ); + $form['student_dob']= array( + '#type'=>'textfield', + '#title'=>t('student_dob'), + '#default_value'=>$sql_select->student_dob, + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => 'Submit', + '#submit' => array('editstudent_form_submit'), + ); + return $form; + + } + /* + * Edit student form submit + */ + function editstudent_form_submit($form,$form_state){ + $student_name = $form_state['values']['student_name']; + $student_email= $form_state['values']['student_email']; + $student_dob= $form_state['values']['student_dob']; + $student_id= $form_state['values']['student_id']; + + + $values = array( + 'student_name' =>$student_name, + 'student_email'=>$student_email, + 'student_dob'=>$student_dob, + ); + + db_update('sch_student') + ->fields($values) + ->condition('student_id',$student_id,'=') + ->execute(); + drupal_set_message(t('Changes updated')); + drupal_goto('students_list page'); + + } + /* + * Get Teacher form + */ + function school_teacher_form($form,$form_state){ + $form['teacher_name'] =array( + '#title' =>t('teacher_name'), + '#type' => 'textfield', + '#required' => TRUE, + ); + + $form['teacher_email']=array( + '#title' =>t('teacher_email'), + '#type' => 'textfield', + '#required' => TRUE, + ); + $form['teacher_dob']=array( + + '#title' =>t('teacher_dob'), + '#type' => 'textfield', + '#required' => TRUE, + ); + $form['submit']=array( + '#value' => 'submit', + '#type'=> 'submit', + ); + return $form; + } + /* + * Store teacher in database + */ + function school_teacher_form_submit($form,&$form_state) { + $sql_query1 =db_insert('sch_teacher') + ->fields(array( + 'teacher_name' => $form_state['values']['teacher_name'], + 'teacher_email' =>$form_state['values']['teacher_email'], + 'teacher_dob' =>$form_state['values']['teacher_dob'], + + ) + ) + ->execute(); + drupal_set_message("deatils saved"); + } + /* + * Get subject form + */ + function school_subject_form($form,$form_state){ + $form['subject_name'] =array( + '#title' =>t('subject_name'), + '#type' => 'textfield', + '#required' => TRUE, + ); + $form['submit']=array( + '#value' => 'submit', + '#type'=> 'submit', + ); + return $form; + + } + /* + * Store subject in database + */ + function school_subject_form_submit($form,&$form_state) { + $sql_query2 =db_insert('sch_subject') + ->fields(array( + 'subject_name' => $form_state['values']['subject_name'], + + ) + ) + ->execute(); + drupal_set_message("deatils saved"); + } + + /* + * Get class form + */ + function school_class_form($form,$form_state){ + $form['class_name'] =array( + '#title' =>t('class_name'), + '#type' => 'textfield', + '#required' => TRUE, + ); + $form['submit']=array( + '#value' => 'submit', + '#type'=> 'submit', + ); + return $form; + + } + /* + * Store class in database + */ + function school_class_form_submit($form,&$form_state) { + $sql_query2 =db_insert('sch_class') + ->fields(array( + 'class_name' => $form_state['values']['class_name'], + + ) + ) + ->execute(); + drupal_set_message("deatils saved"); + } + + +/* + function school_import_form_submit($form,$form_state){ + $transaction =$db_transaction(); + $file =$form_state['storage']['$file']; + /* $db_insert('sch_student')-> + fields(array( + 'student_id'=>$form_state['values']['student_id'], + 'student_name'=>$form_state['values']['student_name'], + 'student_email'=>$form_state['values']['student_email'], + )) + ->execute(); + + // $row =1; + //$handle= fopen('student_importer.csv', "r"); + if(($handle= fopen('student_importer.csv', "r"))!==FALSE){ + while(($data= fgetcsv($handle, 100,","))!== FALSE){ + // $num =count($data); + // echo $num; + // $row++; + $operations =array( + 'school_import_batchprocessing',array($data), + ); + } + $batch = array( + 'title'=>t("Importing file.."), + 'operations'=>$operations, + 'finished' => 'school_import_finished', + 'error_message'=>t('importing encountered error'), + ); + batch_set($batch); + fclose($handle); + } + + $csv_uri = $node->field_csv_file['und'][0]['uri']; + $handle = fopen($csv_uri, 'r'); + + $row = fgetcsv($handle); + $columns = array(); + foreach ($row as $i => $header) { + $columns[$i] = trim($header); + } + while ($row = fgetcsv($handle)) { + $record = array(); + foreach ($row as $i => $field) { + $record[$columns[$i]] = $field; + } + drupal_write_record('sch_student', $record); +} + fclose($handle); +} + + +function school_import_batchprocessing($data){ + $student_id =$data[0]; + $student_name=$data[1]; + $student_email =$data[2]; -} \ No newline at end of file + $node = new stdClass(); + $node ->type='page'; + $node ->status =1; //published automaticaly + $node ->$student_id; + $node ->$student_name; + $node ->$student_email; + + node_save($node); + +} +function school_import_finished(){ + drupal_set_message("Importing is finished"); +} + +*/ + + + function school_views_api(){ + return array( + 'api'=>3, + 'path'=> drupal_get_path('module', 'school'), + ); +} diff --git a/modules/school/school.views.inc b/modules/school/school.views.inc new file mode 100644 index 0000000..f76ce87 --- /dev/null +++ b/modules/school/school.views.inc @@ -0,0 +1,167 @@ +'student_id', + 'title'=>t('Students'), + 'help'=>t('help'), + ); + + + $data['sch_student']['student_id'] = array( + 'title'=>'Student_Id', + 'help'=>t('Student_Id'), + 'field'=>array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + ); + $data['sch_student']['student_name'] = array( + 'title'=>'Student_Name', + 'help'=>t('Student_Name'), + 'field'=>array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + ); + $data['sch_student']['student_email'] = array( + 'title'=>'Student_email', + 'help'=>t('Student_email'), + 'field'=>array( + 'handler' => 'views_handler_field', + + ), + ); + + $data['sch_student']['student_dob'] = array( + 'title'=>'Student_dob', + 'help'=>t('Student_dob'), + 'field'=>array( + 'handler' => 'views_handler_field', + + ), + ); + +} + +function _school_sch_teacher(&$data){ + $data['sch_teacher']['table']['group']=t('Teacher'); + $data['sch_teacher']['table']['base']= array( + 'field'=>'teacher_id', + 'title'=>t('Teacher'), + 'help'=>t('help'), + ); + + + $data['sch_teacher']['teacher_id'] = array( + 'title'=>'Teacher_Id', + 'help'=>t('Teacher_Id'), + 'field'=>array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + ); + $data['sch_teacher']['teacher_name'] = array( + 'title'=>'Teacher_Name', + 'help'=>t('Teacher_Name'), + 'field'=>array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + ); + $data['sch_teacher']['teacher_email'] = array( + 'title'=>'Teacher_email', + 'help'=>t('Teacher_email'), + 'field'=>array( + 'handler' => 'views_handler_field', + + ), + ); + + $data['sch_teacher']['teacher_dob'] = array( + 'title'=>'Teacher_dob', + 'help'=>t('Teacher_dob'), + 'field'=>array( + 'handler' => 'views_handler_field', + + ), + ); + +} + + +function _school_sch_subject(&$data){ + $data['sch_subject']['table']['group']=t('Subject'); + $data['sch_subject']['table']['base']= array( + 'field'=>'subject_id', + 'title'=>t('Subject'), + 'help'=>t('help'), + ); + + + $data['sch_subject']['subject_id'] = array( + 'title'=>'subject_Id', + 'help'=>t('subject_Id'), + 'field'=>array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + 'relationship' => array( + 'title' => t('Teacher'), + 'help' => t('Teacher'), + 'handler' => 'views_handler_relationship', + 'base' => 'Teacher', + 'base field' => 'teacher_id', + 'field' => 'teacher_id', + 'label' => t('Teacher'), + ), + ); + $data['sch_subject']['subject_name'] = array( + 'title'=>'Subject_Name', + 'help'=>t('Subject_Name'), + 'field'=>array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + ); + +} + +function _school_sch_class(&$data){ + $data['sch_class']['table']['group']=t('class'); + $data['sch_class']['table']['base']= array( + 'field'=>'class_id', + 'title'=>t('class'), + 'help'=>t('help'), + ); + + + $data['sch_class']['class_id'] = array( + 'title'=>'class_Id', + 'help'=>t('class_Id'), + 'field'=>array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + ); + $data['sch_class']['class_name'] = array( + 'title'=>'class_Name', + 'help'=>t('class_Name'), + 'field'=>array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + ); +} \ No newline at end of file From cf9075bdaf08dcf566750841c11f913e89e3fc2e Mon Sep 17 00:00:00 2001 From: prameela Date: Tue, 20 Jun 2017 14:09:42 +0530 Subject: [PATCH 4/4] views changes --- .../sch_imports/sch_imports.features.inc | 14 ++ modules/features/sch_imports/sch_imports.info | 17 ++ .../features/sch_imports/sch_imports.module | 6 + .../FeedsImporterSchoolStudentsUpload.inc | 125 +++++++++++++++ modules/sch_importer/sch_importer.info | 10 ++ modules/sch_importer/sch_importer.module | 28 ++++ modules/school/school.module | 149 +++++++----------- modules/school/school.views.inc | 10 +- 8 files changed, 262 insertions(+), 97 deletions(-) create mode 100644 modules/features/sch_imports/sch_imports.features.inc create mode 100644 modules/features/sch_imports/sch_imports.info create mode 100644 modules/features/sch_imports/sch_imports.module create mode 100644 modules/sch_importer/FeedsImporterSchoolStudentsUpload.inc create mode 100644 modules/sch_importer/sch_importer.info create mode 100644 modules/sch_importer/sch_importer.module diff --git a/modules/features/sch_imports/sch_imports.features.inc b/modules/features/sch_imports/sch_imports.features.inc new file mode 100644 index 0000000..ad5322a --- /dev/null +++ b/modules/features/sch_imports/sch_imports.features.inc @@ -0,0 +1,14 @@ + "1"); + } +} \ No newline at end of file diff --git a/modules/features/sch_imports/sch_imports.info b/modules/features/sch_imports/sch_imports.info new file mode 100644 index 0000000..cff8fe7 --- /dev/null +++ b/modules/features/sch_imports/sch_imports.info @@ -0,0 +1,17 @@ +name = School Imports Feature +core = 7.x +package = school +version = 7.x-1.0 +project = sch_imports +dependencies[] = ctools +dependencies[] = entityreference +dependencies[] = features +dependencies[] = feeds +dependencies[] = sch_importer +dependencies[] = school +dependencies[] = options +dependencies[] = taxonomy +dependencies[] = text +features[ctools][] = feeds:feeds_importer_default:1 +features[features_api][] = api:2 +features[feeds_importer][] = school_students_upload diff --git a/modules/features/sch_imports/sch_imports.module b/modules/features/sch_imports/sch_imports.module new file mode 100644 index 0000000..18de55b --- /dev/null +++ b/modules/features/sch_imports/sch_imports.module @@ -0,0 +1,6 @@ +data; + $errors = $data['errors']; + $row = $data['row']; + } + $col_map = array(); + foreach ($this->config['mappings'] as $mapping) { + $col_map[drupal_strtolower($mapping['source'])] = $mapping['target']; + } + $students = db_select('sch_student',s)->fields('s', array('student_id', 'student_id'))->execute()->fetchAllKeyed(); + $mapping = $this->getMappingTargets(); + while($item =$parser_result->shiftItem()){ + $row++; + $error =FALSE; + $data = array(); + foreach ($item as $key => $lvalue){ + $value = trim($lvalue); + $msg = ''; + if (!empty($value)) { + if (isset($mapping[$col_map[$key]]['length']) && strlen($value) > $mapping[$col_map[$key]]['length']) { + $msg = 'Field ' . $mapping[$col_map[$key]]['student_name'] . ' must be less than or equal to ' . $mapping[$col_map[$key]]['length'] . ' characters in row ' . $row; + $error = TRUE; + } + } + elseif ($mapping[$col_map[$key]]['mandatory']) { + $msg = 'Field ' . $mapping[$col_map[$key]]['student_name'] . ' cannot be empty in row ' . $row; + $error = TRUE; + } + + } + if (!$error) { + //update if is existing + try { + if (isset($students[$data['student_id']])) { + if (!empty($students[$data['student_id']])) { + db_update('sch_student')->fields($data)->condition('student_id', $students[$data['student_id']], '=')->execute(); + } + } + else { + //else insert + $iquery = db_insert('sch_student')->fields($data)->execute(); + + } + } + catch (Exception $ex) { + $transaction->rollback(); + watchdog_exception('php', $ex); + } + } + } + if ($source->progressImporting() == FEEDS_BATCH_COMPLETE) { + cache_set('sch_importer_status', array('errors' => $errors, 'row' => $row)); + cache_clear_all('sch_importer_status_progress', 'cache'); + } + else { + cache_set('sch_importer_status_progress', array('errors' => $errors, 'row' => $row)); + } + } + + protected function entityInfo() { + $info = parent::entityInfo(); + $info['label plural'] = t('Entries'); + return $info; + } + + public function getMappingTargets() { + return array( + + 'student_name' => array( + 'name' => t('Student_name'), + 'description' => t('Student Name'), + 'mandatory' => TRUE, + 'length' => 10, + 'exists' => TRUE + ), + 'student_email' => array( + 'name' => t('Student_email'), + 'description' => t('Student Email'), + 'mandatory' => TRUE, + 'length' => 20, + 'exists' => TRUE + ), + ); + } +public function itemCount(FeedsSource $source) { + $query = db_select('sch_student', 's'); + $query->addExpression('count(*)'); + return $query->execute()->fetchField(); +} +} \ No newline at end of file diff --git a/modules/sch_importer/sch_importer.info b/modules/sch_importer/sch_importer.info new file mode 100644 index 0000000..2bfbc57 --- /dev/null +++ b/modules/sch_importer/sch_importer.info @@ -0,0 +1,10 @@ +name=School Bulk Upload +description=school bulk upload +core = 7.x +package = school + + +dependencies[] = feeds +dependencies[] = feeds_ui + +files[] = FeedsImporterSchoolStudentsUpload.inc diff --git a/modules/sch_importer/sch_importer.module b/modules/sch_importer/sch_importer.module new file mode 100644 index 0000000..86374e4 --- /dev/null +++ b/modules/sch_importer/sch_importer.module @@ -0,0 +1,28 @@ + 'Upload school students details', + 'description' => 'Imports school students details', + 'handler' => array( + 'parent' => 'FeedsProcessor', // A plugin needs to derive either directly or indirectly from FeedsFetcher, FeedsParser or FeedsProcessor. + 'class' => 'FeedsImporterSchoolStudentsUpload', + 'file' => 'FeedsImporterSchoolStudentsUpload.inc', + 'path' => drupal_get_path('module', 'sch_importer'), + ), + ); + return $info; + } + + + diff --git a/modules/school/school.module b/modules/school/school.module index 6aaee5b..20f9c1a 100644 --- a/modules/school/school.module +++ b/modules/school/school.module @@ -126,8 +126,14 @@ function school_menu(){ 'access arguments' => array('access school content'), 'access callback'=>TRUE, ); + $items['subject/autocomplete'] = array( + 'type' => MENU_CALLBACK, + 'title' => 'Subject auto complete', + 'page callback' => 'school_subject_autocomplete', + ); return $items; } +/** function school_import_form($form,&$form_state){ $form['notes'] = array( '#type' => 'markup', @@ -150,24 +156,30 @@ function school_import_form($form,&$form_state){ ); return $form; } + * + */ + /* * Get student form */ function school_student_form($form,$form_state){ $form['student_name'] =array( - '#title' =>t('student_name'), + '#title' =>t('Name'), '#type' => 'textfield', + '#size'=>20, '#required' => TRUE, ); $form['student_email']=array( - '#title' =>t('student_email'), + '#title' =>t('Email'), '#type' => 'textfield', + '#size'=>20, '#required' => TRUE, ); $form['student_dob']=array( - '#title' =>t('student_dob'), + '#title' =>t('Date of Birth'), '#type' => 'textfield', + '#size'=>20, '#required' => TRUE, ); $form['submit']=array( @@ -185,7 +197,7 @@ function school_import_form($form,&$form_state){ ->fields(array( 'student_name' => $form_state['values']['student_name'], 'student_email' =>$form_state['values']['student_email'], - 'student_dob'=>$form_state['values']['student_dob'], + 'student_dob'=> strtotime($form_state['values']['student_dob']), ) ) @@ -207,8 +219,8 @@ function school_import_form($form,&$form_state){ l($data->student_id,'studentview_page/'.$data->student_id), $data ->student_name, $data->student_email, - $data->student_dob, - l('action',"editstudent/$data->student_id/edit"), + format_date($data->student_dob), + l('edit',"editstudent/$data->student_id/edit"), ); } $output = theme_table( @@ -273,18 +285,21 @@ function school_import_form($form,&$form_state){ ); $form['student_name']= array( '#type'=>'textfield', - '#title'=>t('student_name'), + '#title'=>t('Name'), + '#size'=>20, '#default_value'=>$sql_select->student_name, ); $form['student_email']= array( '#type'=>'textfield', - '#title'=>t('student_email'), + '#size'=>20, + '#title'=>t('Email'), '#default_value'=>$sql_select->student_email, ); $form['student_dob']= array( '#type'=>'textfield', - '#title'=>t('student_dob'), - '#default_value'=>$sql_select->student_dob, + '#title'=>t('Date of Birth'), + '#size'=>20, + '#default_value'=>format_date($sql_select->student_dob), ); $form['submit'] = array( '#type' => 'submit', @@ -300,14 +315,14 @@ function school_import_form($form,&$form_state){ function editstudent_form_submit($form,$form_state){ $student_name = $form_state['values']['student_name']; $student_email= $form_state['values']['student_email']; - $student_dob= $form_state['values']['student_dob']; + $student_dob= strtotime($form_state['values']['student_dob']); $student_id= $form_state['values']['student_id']; $values = array( 'student_name' =>$student_name, 'student_email'=>$student_email, - 'student_dob'=>$student_dob, + 'student_dob'=>strtotime($student_dob), ); db_update('sch_student') @@ -323,20 +338,23 @@ function school_import_form($form,&$form_state){ */ function school_teacher_form($form,$form_state){ $form['teacher_name'] =array( - '#title' =>t('teacher_name'), + '#title' =>t('Name'), '#type' => 'textfield', + '#size'=>20, '#required' => TRUE, ); $form['teacher_email']=array( - '#title' =>t('teacher_email'), + '#title' =>t('Email'), '#type' => 'textfield', + '#size'=>20, '#required' => TRUE, ); $form['teacher_dob']=array( - '#title' =>t('teacher_dob'), + '#title' =>t('Date of Birth'), '#type' => 'textfield', + '#size'=>20, '#required' => TRUE, ); $form['submit']=array( @@ -365,8 +383,9 @@ function school_import_form($form,&$form_state){ */ function school_subject_form($form,$form_state){ $form['subject_name'] =array( - '#title' =>t('subject_name'), + '#title' =>t('Name'), '#type' => 'textfield', + '#size'=>20, '#required' => TRUE, ); $form['submit']=array( @@ -389,14 +408,30 @@ function school_import_form($form,&$form_state){ ->execute(); drupal_set_message("deatils saved"); } - + /* + * Subject auto complete + */ + function school_subject_autocomplete($string =''){ + $matches = array(); + $query = db_select('sch_subject','sub')->fields('sub'); + $result = $query->condition('sub.subject_name','%'.db_like($string),'%'.'LIKE')->execute(); + foreach($result as $row){ + $matches["$row->subject_name [ID: $row->subject_id]"] = check_plain($row->subject_name); + + } + if(empty($matches)){ + $matches [] = t('No result found'); + } + return drupal_json_output($matches); + } /* * Get class form */ function school_class_form($form,$form_state){ $form['class_name'] =array( - '#title' =>t('class_name'), + '#title' =>t('Name'), '#type' => 'textfield', + '#size'=>20, '#required' => TRUE, ); $form['submit']=array( @@ -418,83 +453,7 @@ function school_import_form($form,&$form_state){ ) ->execute(); drupal_set_message("deatils saved"); - } - - -/* - function school_import_form_submit($form,$form_state){ - $transaction =$db_transaction(); - $file =$form_state['storage']['$file']; - /* $db_insert('sch_student')-> - fields(array( - 'student_id'=>$form_state['values']['student_id'], - 'student_name'=>$form_state['values']['student_name'], - 'student_email'=>$form_state['values']['student_email'], - )) - ->execute(); - - // $row =1; - //$handle= fopen('student_importer.csv', "r"); - if(($handle= fopen('student_importer.csv', "r"))!==FALSE){ - while(($data= fgetcsv($handle, 100,","))!== FALSE){ - // $num =count($data); - // echo $num; - // $row++; - $operations =array( - 'school_import_batchprocessing',array($data), - ); - } - $batch = array( - 'title'=>t("Importing file.."), - 'operations'=>$operations, - 'finished' => 'school_import_finished', - 'error_message'=>t('importing encountered error'), - ); - batch_set($batch); - fclose($handle); - } - - $csv_uri = $node->field_csv_file['und'][0]['uri']; - $handle = fopen($csv_uri, 'r'); - - $row = fgetcsv($handle); - $columns = array(); - foreach ($row as $i => $header) { - $columns[$i] = trim($header); - } - while ($row = fgetcsv($handle)) { - $record = array(); - foreach ($row as $i => $field) { - $record[$columns[$i]] = $field; - } - drupal_write_record('sch_student', $record); -} - fclose($handle); -} - - -function school_import_batchprocessing($data){ - $student_id =$data[0]; - $student_name=$data[1]; - $student_email =$data[2]; - - $node = new stdClass(); - $node ->type='page'; - $node ->status =1; //published automaticaly - $node ->$student_id; - $node ->$student_name; - $node ->$student_email; - - node_save($node); - -} -function school_import_finished(){ - drupal_set_message("Importing is finished"); -} - -*/ - - + } function school_views_api(){ return array( 'api'=>3, diff --git a/modules/school/school.views.inc b/modules/school/school.views.inc index f76ce87..7190d1a 100644 --- a/modules/school/school.views.inc +++ b/modules/school/school.views.inc @@ -27,6 +27,12 @@ function _school_sch_student(&$data){ 'handler' => 'views_handler_field', 'click sortable' => TRUE, ), + 'filter' => array( + 'handler' => 'views_handler_filter' + ), + 'sort' => array( + 'handler' => 'views_handler_sort' + ), ); $data['sch_student']['student_name'] = array( 'title'=>'Student_Name', @@ -49,7 +55,7 @@ function _school_sch_student(&$data){ 'title'=>'Student_dob', 'help'=>t('Student_dob'), 'field'=>array( - 'handler' => 'views_handler_field', + 'handler' => 'views_handler_field_date', ), ); @@ -94,7 +100,7 @@ function _school_sch_teacher(&$data){ 'title'=>'Teacher_dob', 'help'=>t('Teacher_dob'), 'field'=>array( - 'handler' => 'views_handler_field', + 'handler' => 'views_handler_field_date', ), );