• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

cms/modules/faculty.lib.php

Go to the documentation of this file.
00001 <?php
00002 if(!defined('__PRAGYAN_CMS'))
00003 { 
00004         header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
00005         echo "<h1>403 Forbidden<h1><h4>You are not authorized to access the page.</h4>";
00006         echo '<hr/>'.$_SERVER['SERVER_SIGNATURE'];
00007         exit(1);
00008 }
00009 class faculty implements module, fileuploadable{
00010         private $userId;
00011         private $moduleComponentId;
00012         private $action;
00013 
00014         public function getHtml($gotuid, $gotmoduleComponentId, $gotaction) {
00015                 $this->userId = $gotuid;
00016                 $this->moduleComponentId = $gotmoduleComponentId;
00017                 $this->action = $gotaction;
00018 
00019                 if ($this->action == "view")
00020                         return $this->actionView();
00021                 if ($this->action == "edit")
00022                         return $this->actionEdit();
00023                 }
00024         public static function getFileAccessPermission($pageId,$moduleComponentId,$userId, $fileName) {
00025                 return getPermissions($userId, $pageId, "view");
00026                 }
00027         public static function getUploadableFileProperties(& $fileTypesArray, & $maxFileSizeInBytes) {
00028                 $fileTypesArray = array (
00029                         'jpg',
00030                         'jpeg',
00031                         'png',
00032                         'gif'
00033                 );
00034                 $maxFileSizeInBytes = 2 * 1024 * 1024;
00035         }
00036         public function actionView() {
00037                 global $sourceFolder;
00038                 $query = "SELECT * FROM faculty_content WHERE page_modulecomponentid=" . $this->moduleComponentId;
00039                 $result = mysql_query($query);
00040                 if($row = mysql_fetch_assoc($result)) {
00041                         $name = $row['Name'];
00042                         $email = $row['Email'];
00043                         $image = $row['Image'];
00044                         $qualification = $row['Qualifications'];
00045                         $qua = explode(',', $qualification);
00046                         $subject = $row['Subjects of Interest'];
00047                         $contact = $row['Contact Address'];
00048                         $con = explode(',', $contact);
00049                         }
00050                 require_once($sourceFolder."/upload.lib.php");
00051                 $arr = getUploadedFiles($this->moduleComponentId, 'faculty');
00052                 $j = 0;
00053                 while($arr[$j]['upload_filename']){
00054                         if($arr[$j]['upload_filename'] == $image){
00055                                 break;
00056                                 }
00057                         $j++;
00058                         }
00059                 $content = "<h1>" . $name . "</h1><p>&nbsp;</p><center><img border=\"0\" src=\"./" . $arr[$j]['upload_filename'] . "\" alt=\"". $name . "\"></center><p>&nbsp;</p><p>" . $email . "</p><h2>Qualifications</h2><ul>";
00060                 $i = 0;
00061                 while($qua[$i]){
00062                         $content .= "<li>" . $qua[$i] . "</li>";
00063                         $i++;
00064                         }
00065                 $content .= "</ul><h2>Subjects of Interest</h2><p>" . $subject . "</p><h2>Contact Address</h2><address>";
00066                 $i = 0;
00067                 while($qua[$i]){
00068                         $content .= $con[$i] . "<br/>";
00069                         $i++;
00070                         }
00071                 $content .= "</address>";
00072                 return $content;
00073                 }
00074                 
00075         public function actionEdit() {
00076                 global $sourceFolder;
00077                 require_once($sourceFolder."/upload.lib.php");
00078                 $allowableTypes = array(
00079                         'jpeg',
00080                         'jpg',
00081                         'gif',
00082                         'png'
00083                         );
00084                         
00085                 submitFileUploadForm($this->moduleComponentId,"faculty",$this->userId,UPLOAD_SIZE_LIMIT,$allowableTypes);
00086                 if(isset($_POST['submit']) && !empty($_POST['name']) && !empty($_POST['image']) && !empty($_POST['email']) && !empty($_POST['qual']) && !empty($_POST['subject']) && !empty($_POST['contact'])){
00087                         $facquery1 = "UPDATE `faculty_content` SET `Name`='{$_POST['name']}', `Image`='{$_POST['image']}', `Email`='{$_POST['email']}', `Qualifications`='{$_POST['qual']}', `Subjects of Interest`='{$_POST['subject']}', `Contact Address`='{$_POST['contact']}' WHERE `page_modulecomponentid`=$moduleComponentId";
00088                         $facresult1 = mysql_query($facquery1);
00089                         }
00090                 $content2 =<<<FORM
00091                                                   <form action="./+edit" method="post">
00092                                                         <p>Name: <input type="text" name="name"></p>
00093                                                         <p>Email: <input type="text" name="email"></p>
00094                                                         <p>Image Name uploaded: <input type="text" name="image"></p>
00095                                                         <p>Qualifications: <textarea rows="5" cols="50" name="qual"></textarea></p>
00096                                                         <p>Subjects of Interest: <textarea rows="5" cols="50" name="subject"></textarea></p>
00097                                                         <p>Contact Address: <textarea rows="5" cols="50" name="contact"></textarea></p>
00098 FORM;
00099                 $content2 .=<<<FILE
00100                                               <input type="button" value="Cancel" onclick="submitfacultyformCancel(this);"><input type="submit" name="submit" value="Save"><input type="button" value="Preview" onclick="submitfacultyformPreview(this)">
00101                                                          </form>
00102                                                  <script language="javascript">
00103                                                 function submitfacultyformPreview(butt) {
00104                                                         butt.form.action = "./+edit&preview=yes#preview";
00105                                                         butt.form.submit();
00106                                                 }
00107                                                 function submitfacultyformCancel(butt) {
00108                                                         butt.form.action="./+view";
00109                                                         butt.form.submit();
00110                                                 }
00111                                             </script><br />
00112                                             <fieldset>
00113                                                 <legend><a name="files">Images :</a></legend>
00114                                                         Uploaded Images : <br />
00115 FILE;
00116                 $content2 .= getUploadedFilePreviewDeleteForm($this->moduleComponentId,"faculty",'./+edit');
00117                 $content2 .= '<br />Upload files : <br />'.getFileUploadForm($this->moduleComponentId,"faculty",'./+edit',UPLOAD_SIZE_LIMIT,5).'</fieldset>';
00118                 
00119                 return $content2;
00120                 }
00121                 
00122         public function createModule(&$moduleComponentId) {
00123                 $query = "SELECT MAX(page_modulecomponentid) as MAX FROM `faculty_content` ";
00124                 $result = mysql_query($query);
00125                 $row = mysql_fetch_assoc($result);
00126                 $compId = $row['MAX'] + 1;
00127 
00128                 $query = "INSERT INTO `faculty_content` (`page_modulecomponentid` ,`Name` ,`Email` ,`Qualifications` ,`Subjects of Interest` ,`Contact Address`)VALUES ('$compId', 'New member', 'New member', 'New member', 'New member', 'New member')";
00129                 $result = mysql_query($query);
00130                 if (mysql_affected_rows()) {
00131                         $moduleComponentId = $compId;
00132                         return true;
00133                 } else
00134                         return false;
00135         }
00136         public function deleteModule($moduleComponentId) {
00137                 $query = "DELETE FROM `faculty_content` WHERE `page_modulecomponentid`=$moduleComponentId";
00138                 $result = mysql_query($query);
00139                 if ((mysql_affected_rows()) >= 1)
00140                         return true;
00141                 else
00142                         return false;
00143 
00144         }
00145         public function copyModule($moduleComponentId) {
00146                 $query = "SELECT * FROM `faculty_content` WHERE `page_modulecomponentid`=$moduleComponentId";
00147                 $result = mysql_query($query);
00148                 $content = mysql_fetch_assoc($result);
00149                 $query = "SELECT MAX(page_modulecomponentid) as MAX FROM `faculty_content` ";
00150                 $result = mysql_query($query);
00151                 $row = mysql_fetch_assoc($result);
00152                 $compId = $row['MAX'] + 1;
00153 
00154                 $query = "INSERT INTO `faculty_content` (`page_modulecomponentid` ,`Name` ,`Email` ,`Qualifications` ,`Subjects of Interest` ,`Contact Address`)VALUES ('$compId', '". $content['Name'] . "', '" .$content['Email'] . "', '" .$content['Qualifications'] . "', '" . $content['Subjects of Interest'] . "', '" .$content['Contact Address'] . "')";
00155                 mysql_query($query);
00156                 if (mysql_affected_rows()) {
00157                         return $compId;
00158                 } else
00159                         return false;
00160         }
00161 
00162 
00163         }
00164 ?>

Generated on Sun Jan 2 2011 04:55:31 for Pragyan CMS by  doxygen 1.7.1