Commit 815d4c9bf2a142fdf24f9c85ff3b0481240478da
1 parent
4a72cdd3
error checkin when creating
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@681 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
82 additions
and
202 deletions
lib/units/Unit.inc
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* Class Unit | |
| 4 | -* Represents a unit as per the database table units | |
| 3 | +* emailLink.php | |
| 5 | 4 | * |
| 6 | -* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 7 | -* @date 21 January 2003 | |
| 8 | -* @package lib.units | |
| 5 | +* Creates the form and functionaility for emailing a link to some1 | |
| 6 | +* | |
| 7 | +* | |
| 8 | +* @author Mukhtar Dharsey | |
| 9 | +* @date 22 January 2003 | |
| 9 | 10 | */ |
| 10 | 11 | |
| 11 | -class Unit { | |
| 12 | - | |
| 13 | - /** object's primary key */ | |
| 14 | - var $iId; | |
| 15 | - /** unit's name */ | |
| 16 | - var $sName; | |
| 17 | - /** primary key to which the unit belongs */ | |
| 18 | - var $iOrganisationID; | |
| 19 | - /** primary key of parent unit */ | |
| 20 | - var $iParentID; | |
| 12 | + | |
| 13 | +require_once("../../../../config/dmsDefaults.php"); | |
| 14 | + | |
| 15 | +global $default; | |
| 16 | +require_once("$default->owl_fs_root/lib/email/Email.inc"); | |
| 21 | 17 | |
| 22 | - function Unit($sNewName, $iNewOrganisationID, $iNewParentID) { | |
| 23 | - //object has not been created in database yet | |
| 24 | - $this->iId = -1; | |
| 25 | - $this->sName = $sNewName; | |
| 26 | - $this->iOrganisationID = $iNewOrganisationID; | |
| 27 | - $this->iParentID = $iNewParentID; | |
| 28 | - } | |
| 29 | 18 | |
| 30 | - /** | |
| 31 | - * Get the object's primary key | |
| 32 | - * | |
| 33 | - * @return int object's primary key | |
| 34 | - * | |
| 35 | - */ | |
| 36 | - function getID() { | |
| 37 | - return $this->iId; | |
| 38 | - } | |
| 19 | +if(checkSession()) | |
| 20 | +{ | |
| 21 | + | |
| 22 | + | |
| 23 | +// include the page template (with navbar) | |
| 24 | +require_once("$default->owl_fs_root/presentation/webPageTemplate.inc"); | |
| 25 | + // when email button sent..send email | |
| 26 | +if ($submit) | |
| 27 | +{ | |
| 28 | + //set up body and link | |
| 39 | 29 | |
| 40 | - /** | |
| 41 | - * Get the unit's name | |
| 42 | - * | |
| 43 | - * @return String unit's name | |
| 44 | - * | |
| 45 | - */ | |
| 46 | - function getName() { | |
| 47 | - return $this->sName; | |
| 48 | - } | |
| 30 | + $body = "<b> Here's a interesting link: </b>"; | |
| 31 | + $docID = $fDocumentID; | |
| 32 | + //link has to be changed to respective server where everything is stored. | |
| 33 | + $link = $default->owl_url . "control.php?action=viewDocument&fDocumentID=" . $docID; | |
| 49 | 34 | |
| 50 | - /** | |
| 51 | - * Set the unit's name | |
| 52 | - * | |
| 53 | - * @param String Unit's name | |
| 54 | - * | |
| 55 | - */ | |
| 56 | - function setName($sNewValue) { | |
| 57 | - $this->sName = $sNewValue; | |
| 58 | - } | |
| 35 | + $hyperlink = "<a href = ". $link .">" . $link. "</a>"; | |
| 59 | 36 | |
| 60 | - /** | |
| 61 | - * Get the primary key of the organisation to which this unit belongs | |
| 62 | - * | |
| 63 | - * @return int primary key of organisation to which this unit belongs | |
| 64 | - * | |
| 65 | - */ | |
| 66 | - function getOrganisationID() { | |
| 67 | - return $this->iOrganisationID; | |
| 68 | - } | |
| 37 | + //create email object | |
| 38 | + $emailLink= new Email(); | |
| 39 | + //send email | |
| 40 | + $success = $emailLink->sendHyperLink($fromEmail,$fromName,$toEmail,$subject,$body, $hyperlink); | |
| 69 | 41 | |
| 70 | - /** | |
| 71 | - * Set the primary key of the organisation to which this unit belongs | |
| 72 | - * | |
| 73 | - * @param int Primary key of organisation to which this unit belongs | |
| 74 | - * | |
| 75 | - */ | |
| 76 | - function setOrganisationID($iNewValue) { | |
| 77 | - $this->iOrganisationID = $iNewValue; | |
| 42 | + //if successful ..rerender the page | |
| 43 | + if($success == True) | |
| 44 | + { | |
| 45 | + $Center = "<br>Email Successfully Sent</br>"; | |
| 46 | + $oPatternCustom = & new PatternCustom(); | |
| 47 | + $oPatternCustom->setHtml($Center); | |
| 48 | + $main->setCentralPayload($oPatternCustom); | |
| 49 | + $main->render(); | |
| 78 | 50 | } |
| 79 | - | |
| 80 | - /** | |
| 81 | - * Get the primary key of the parent unit | |
| 82 | - * | |
| 83 | - * @return int primary key of parent unit | |
| 84 | - * | |
| 85 | - */ | |
| 86 | - function getParentID() { | |
| 87 | - return $this->iParentID; | |
| 51 | + Else | |
| 52 | + { | |
| 53 | + $Center = "<br>Email Unsuccessful</br>"; | |
| 54 | + $oPatternCustom = & new PatternCustom(); | |
| 55 | + $oPatternCustom->setHtml($Center); | |
| 56 | + $main->setCentralPayload($oPatternCustom); | |
| 57 | + $main->render(); | |
| 88 | 58 | } |
| 89 | 59 | |
| 90 | - /** | |
| 91 | - * Set the primary key of the parent unit | |
| 92 | - * | |
| 93 | - * @param int Primary key of parent unit | |
| 94 | - * | |
| 95 | - */ | |
| 96 | - function setParentID($iNewValue) { | |
| 97 | - $this->iParentID = $iNewValue; | |
| 98 | - } | |
| 60 | + | |
| 99 | 61 | |
| 100 | - /** | |
| 101 | - * Create the current object in the database | |
| 102 | - * | |
| 103 | - * @return boolean on successful store, false otherwise and set $_SESSION["errorMessage"] | |
| 104 | - * | |
| 105 | - */ | |
| 106 | - function create() { | |
| 107 | - global $default, $lang_err_database, $lang_err_object_exists; | |
| 108 | - //if the object hasn't been created | |
| 109 | - if ($this->iId < 0) { | |
| 110 | - $sql = new Owl_DB(); | |
| 111 | - $result = $sql->query("INSERT INTO " . $default->owl_units_table . " (name, organisation_id, parent_id) VALUES ('" . addslashes($this->sName) . "', $this->iOrganisationID, $this->iParentID)"); | |
| 112 | - if ($result) { | |
| 113 | - $this->iId = $sql->insert_id(); | |
| 114 | - return true; | |
| 115 | - } | |
| 116 | - $_SESSION["errorMessage"] = $lang_err_database; | |
| 117 | - return false; | |
| 118 | - } | |
| 119 | - $_SESSION["errorMessage"] = $lang_err_object_exists . "id = " . $this->iId . " table = $default->owl_units_table"; | |
| 120 | - return false; | |
| 121 | - } | |
| 122 | - | |
| 123 | - /** | |
| 124 | - * Update the values in the database table with the object's current values | |
| 125 | - * | |
| 126 | - * @return boolean true on successful update, false otherwise and set $_SESSION["errorMessage"] | |
| 127 | - * | |
| 128 | - */ | |
| 129 | - function update() { | |
| 130 | - global $default, $lang_err_database, $lang_err_object_key; | |
| 131 | - //only update if the object has been stored | |
| 132 | - if ($this->iId > 0) { | |
| 133 | - $sql = new Owl_DB(); | |
| 134 | - $result = $sql->query("UPDATE " . $default->owl_units_table . " SET name = '" . addslashes($this->sName) . "', organisation_id = $this->iOrganisationID, parent_id = $this->iParentID WHERE id = $this->iId"); | |
| 135 | - if ($result) { | |
| 136 | - return true; | |
| 137 | - } | |
| 138 | - $_SESSION["errorMessage"] = $lang_err_database; | |
| 139 | - return false; | |
| 140 | - } | |
| 141 | - $_SESSION["errorMessage"] = $lang_err_object_key; | |
| 142 | - return false; | |
| 143 | - } | |
| 144 | - | |
| 145 | - /** | |
| 146 | - * Delete the current object from the database | |
| 147 | - * | |
| 148 | - * @return boolean true on successful deletion, false otherwise and set $_SESSION["errorMessage"] | |
| 149 | - * | |
| 150 | - */ | |
| 151 | - function delete() { | |
| 152 | - global $default, $lang_err_database, $lang_err_object_key; | |
| 153 | - //only delete the object if it exists in the database | |
| 154 | - if ($this->iId >= 0) { | |
| 155 | - $sql = new Owl_DB(); | |
| 156 | - $result = $sql->query("DELETE FROM $default->owl_units_table WHERE id = $this->iId"); | |
| 157 | - if ($result) { | |
| 158 | - return true; | |
| 159 | - } | |
| 160 | - $_SESSION["errorMessage"] = $lang_err_database; | |
| 161 | - return false; | |
| 162 | - } | |
| 163 | - $_SESSION["errorMessage"] = $lang_err_object_key; | |
| 164 | - return false; | |
| 165 | - } | |
| 62 | +} | |
| 63 | +//create the necessary HTML for the emailing | |
| 64 | +$Center = " | |
| 65 | + <br> | |
| 66 | + </br> | |
| 67 | + <TABLE BORDER=\"0\" CELLSPACING=\"2\" CELLPADDING=\"2\"> | |
| 68 | + <tr> | |
| 69 | + <td>To Email: <TD WIDTH=\"100%\"><INPUT type=\"Text\" name=\"toEmail\" size=\"30\"></td></td> | |
| 70 | + </tr> | |
| 71 | + <tr> | |
| 72 | + <td>Your Name: <TD WIDTH=\"80%\"><INPUT type=\"Text\" name=\"fromName\" size=\"30\"></td></td> | |
| 73 | + </tr> | |
| 74 | + <tr> | |
| 75 | + <td>Your Email: <TD WIDTH=\"80%\"><INPUT type=\"Text\" name=\"fromEmail\" size=\"30\"></td></td> | |
| 76 | + </tr> | |
| 77 | + <tr> | |
| 78 | + <td>Subject: <TD WIDTH=\"80%\"><INPUT type=\"Text\" name=\"subject\" size=\"30\"></td></td> | |
| 79 | + </tr> | |
| 80 | + <tr> | |
| 81 | + <td> | |
| 82 | + </td> | |
| 83 | + </tr> | |
| 84 | + <tr> | |
| 85 | + <td><center><TD WIDTH=\"80%\"><INPUT type=\"Submit\" name=\"submit\" value=\"Send Email\"></center></td></td> | |
| 86 | + </tr> | |
| 87 | + </table> | |
| 88 | + "; | |
| 166 | 89 | |
| 167 | - /** | |
| 168 | - * Static function. | |
| 169 | - * Given a web_documents primary key it will create a | |
| 170 | - * Unit object and populate it with the | |
| 171 | - * corresponding database values | |
| 172 | - * | |
| 173 | - * @return Unit populated Unit object on successful query, false otherwise and set $_SESSION["errorMessage"] | |
| 174 | - */ | |
| 175 | - function & get($iUnitID) { | |
| 176 | - global $default; | |
| 177 | - $sql = new Owl_DB(); | |
| 178 | - $result = $sql->query("SELECT * FROM $default->owl_units_table WHERE id = $iUnitID"); | |
| 179 | - if ($result) { | |
| 180 | - if ($sql->next_record()) { | |
| 181 | - $oUnit = & new Unit(stripslashes($sql->f("name")), $sql->f("organization_id"), $sql->f("parent_id")); | |
| 182 | - $oUnit->iId = $iUnitID; | |
| 183 | - return $oUnit; | |
| 184 | - } | |
| 185 | - $_SESSION["errorMessage"] = $lang_err_object_not_exist . "id = " . $iUnitID . " table = $default->owl_units_table"; | |
| 186 | - return false; | |
| 187 | - } | |
| 188 | - $_SESSION["errorMessage"] = $lang_err_database; | |
| 189 | - return false; | |
| 190 | - } | |
| 90 | +$oPatternCustom = & new PatternCustom(); | |
| 91 | +$oPatternCustom->setHtml($Center); | |
| 92 | +$main->setCentralPayload($oPatternCustom); | |
| 93 | +$main->setFormAction($_SERVER["PHP_SELF"]); | |
| 94 | +$main->render(); | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 191 | 98 | |
| 192 | -/** | |
| 193 | - * Static function | |
| 194 | - * Get a list of web documents | |
| 195 | - * | |
| 196 | - * @param String Where clause (not required) | |
| 197 | - * | |
| 198 | - * @return Array array of Unit objects, false otherwise and set $_SESSION["errorMessage"] | |
| 199 | - */ | |
| 200 | - function getList($sWhereClause = null) { | |
| 201 | - global $default, $lang_err_database; | |
| 202 | - $aUnitArray; | |
| 203 | - settype($aUnitArray, "array"); | |
| 204 | - $sql = new Owl_DB(); | |
| 205 | - $result = $sql->query("SELECT * FROM " . $default->owl_units_table . (isset($sWhereClause) ? " " . $sWhereClause : "")); | |
| 206 | - if ($result) { | |
| 207 | - $iCount = 0; | |
| 208 | - while ($sql->next_record()) { | |
| 209 | - $oUnit = & Unit::get($sql->f("id")); | |
| 210 | - $aUnitArray[$iCount] = $oUnit; | |
| 211 | - $iCount++; | |
| 212 | - } | |
| 213 | - return $aUnitArray; | |
| 214 | - } | |
| 215 | - $_SESSION["errorMessage"] = $lang_err_database; | |
| 216 | - return false; | |
| 217 | - } | |
| 218 | - | |
| 219 | 99 | } |
| 220 | 100 | |
| 221 | 101 | -?> |
| 102 | +?> | |
| 222 | 103 | \ No newline at end of file | ... | ... |