コード例 #1
0
function dayReferance($date, $format = "d-m-Y")
{
    if (formatDate($date) == formatDate(getCurrentDateTime())) {
        return "Today";
    } elseif (formatDate($date) == formatDate(getPreviousDate(getCurrentDateTime()))) {
        return "Yesterday";
    } else {
        return formatDate($date, $format);
    }
}
コード例 #2
0
 public function postMessage($title, $text)
 {
     $params = ["title" => $title, "text" => $text, "created_by" => $this->session->userdata('user_details')->id, "created_on" => getCurrentDateTime()];
     $this->db->insert($this->table, $params);
     if ($this->db->affected_rows() != 1) {
         return 0;
     } else {
         return $this->db->insert_id();
     }
 }
コード例 #3
0
 public function insertComment($comment, $type, $ref_id)
 {
     $params = ["text" => $comment, "type" => $type, "ref_id" => $ref_id, "created_by" => $this->session->userdata('user_details')->id, "created_on" => getCurrentDateTime()];
     $this->db->insert($this->table, $params);
     if ($this->db->affected_rows() != 1) {
         return false;
     } else {
         return $this->db->insert_id();
     }
 }
コード例 #4
0
ファイル: Model.php プロジェクト: amriterry/HelpNepal
 public function insert()
 {
     $sql = "INSERT INTO {$this->table} ";
     $keys = array_keys($this->data);
     if (!is_null($this->timestamps) && $this->timestamps != false) {
         array_push($keys, "created_at");
         $this->data["created_at"] = getCurrentDateTime();
     }
     $sql .= "(" . join(",", $keys) . ") VALUES (:" . join(",:", $keys) . ")";
     return $this->queryBuilder->run($sql, $this->data);
 }
コード例 #5
0
 function _fieldValues()
 {
     if (empty($this->dDateTime)) {
         $this->dDateTime = getCurrentDateTime();
     }
     if (empty($this->iSessionId)) {
         $this->iSessionId = $_SESSION['sessionID'];
     }
     $oFolder = Folder::get($this->iFolderId);
     // head off the certain breakage down the line.
     if (PEAR::isError($oFolder) || $oFolder === false) {
         $this->bAdminMode = 0;
     } else {
         if (KTBrowseUtil::inAdminMode($oUser, $oFolder)) {
             $this->bAdminMode = 1;
         } else {
             $this->bAdminMode = 0;
         }
     }
     return parent::_fieldValues();
 }
コード例 #6
0
function unlikeItem($userID, $itemID)
{
    $data = new DataAccess('photo');
    $sql = "SELECT like_count FROM items WHERE item_id={$itemID}";
    $resultset = $data->getResultSet($sql);
    $row = $data->getRow($resultset);
    $newitemtotal = $row['like_count'] - 1;
    $sql = "SELECT like_count FROM users WHERE fbid='{$userID}'";
    $resultset = $data->getResultSet($sql);
    $row = $data->getRow($resultset);
    $newusertotal = $row['like_count'] - 1;
    $newtime = getCurrentDateTime();
    $sql = "UPDATE items SET like_count={$newitemtotal} WHERE item_id={$itemID}";
    $data->executeQuery($sql);
    $sql = "UPDATE users SET like_count={$newusertotal} WHERE fbid='{$userID}'";
    $data->executeQuery($sql);
    $sql = "DELETE FROM users_likes WHERE fbid='{$userID}' AND item_id={$itemID}";
    $data->executeQuery($sql);
    $data->dispose();
}
コード例 #7
0
ファイル: forms.inc.php プロジェクト: sfsergey/knowledgetree
 function validate()
 {
     // we first ask each widget to pull its data out.
     // while we do that, we create the storage set for the session
     // that widgets can call on later.
     $raw_data = KTUtil::arrayGet($_REQUEST, 'data');
     $processed_data = array();
     foreach ($this->_widgets as $oWidget) {
         if (PEAR::isError($oWidget)) {
             continue;
         }
         // widgets are expected to place their data in the "basename"
         // entry in the processed data area
         //
         // they should also be able to reconstruct their inputs from this
         // since its what they get later.
         $res = $oWidget->process($raw_data);
         $processed_data = kt_array_merge($processed_data, $res);
     }
     // before we validate ANYTHING we store data into the session
     $store_data = array();
     // we only want to store serialized values here
     foreach ($processed_data as $k => $v) {
         $store_data[$k] = serialize($v);
     }
     $_SESSION['_kt_old_data'][$this->_kt_form_name]['data'] = serialize($store_data);
     $_SESSION['_kt_old_data'][$this->_kt_form_name]['identifier'] = $this->sIdentifier;
     $_SESSION['_kt_old_data'][$this->_kt_form_name]['created'] = getCurrentDateTime();
     $results = array();
     $errors = array();
     // some things can be checked by the actual widgets involved.  These
     // are obvious (e.g. required) and shouldn't require the developer to
     // think about them.
     //
     // to accomplish this, we call each widget's "getValidators" method.
     //
     // note that autovalidation can be turned off for a widget by passing
     // "autovalidate" => "false" in the widget's config.
     $extra_validators = array();
     foreach ($this->_widgets as $oWidget) {
         if (PEAR::isError($oWidget)) {
             continue;
         }
         $res = $oWidget->getValidators();
         if (!is_null($res)) {
             if (is_array($res)) {
                 $extra_validators = kt_array_merge($extra_validators, $res);
             } else {
                 $extra_validators[] = $res;
             }
         }
     }
     $validators = kt_array_merge($extra_validators, $this->_validators);
     foreach ($validators as $oValidator) {
         if (PEAR::isError($oValidator)) {
             // don't bother with broken validators, but warn the user/dev
             $errors['_kt_global'][] = $oValidator->getMessage();
             continue;
         }
         $res = $oValidator->validate($processed_data);
         // results comes out with a set of names and values.
         // these *shouldn't* overlap, so just merge them
         $extra_results = KTUtil::arrayGet($res, 'results', array());
         $results = kt_array_merge($results, $extra_results);
         // errors *can* overlap
         // the format is:
         //   basename => array(errors)
         // so that a given field can have multiple errors
         // from multiple validators
         //
         // there is also a "global" error notice stored against the var
         // _kt_global
         $extra_errors = KTUtil::arrayGet($res, 'errors', array());
         foreach ($extra_errors as $varname => $aErrors) {
             if (is_string($aErrors)) {
                 $errors[$varname][] = $aErrors;
             } else {
                 $errors[$varname] = kt_array_merge($errors[$varname], $aErrors);
             }
         }
     }
     $this->_errors = $errors;
     // store for later use without unserialising
     if (!empty($errors)) {
         $_SESSION['_kt_old_data'][$this->_kt_form_name]['errors'] = serialize($errors);
     }
     //var_dump($errors); exit(0);
     return array('errors' => $errors, 'results' => $results);
 }
コード例 #8
0
 function _recordUpgrade($result)
 {
     if (is_null($this->date)) {
         $this->date = getCurrentDateTime();
     }
     if ($this->parent) {
         $parentid = $this->parent->getDescriptor();
     } else {
         $parentid = null;
     }
     return DBUtil::autoInsert("upgrades", array("descriptor" => $this->getDescriptor(), "description" => $this->description, "date_performed" => $this->date, "result" => $result, "parent" => $parentid));
 }
コード例 #9
0
<?php

require_once 'DataAccess.php';
require_once 'includes/functions.php';
$star = $_POST['star'];
$data = new DataAccess('photo');
$userID = rand(1, 10);
$itemID = $_POST['id'];
$table = $_POST['table'];
$newtime = getCurrentDateTime();
$theItem = getItem($itemID, $table);
$totStar = $theItem['stars'] + $star;
$total = $theItem['like_count'] + 1;
$rating = (int) $totStar / $total;
$table2 = $table . "_votes";
$sql = "UPDATE {$table} SET like_count='{$total}', stars='{$star}', last_liked='{$newtime}',  rating={$rating} WHERE id={$itemID}";
$result = $data->executeQuery($sql);
if ($result) {
    $sql = "INSERT INTO {$table2} VALUES ({$userID}, {$star}, '{$newtime}',{$itemID} )";
    $result2 = $data->executeQuery($sql);
    if ($result2) {
        echo "success";
    } else {
        echo "fail3";
    }
} else {
    echo "fail2";
}
$data->dispose();
コード例 #10
0
ファイル: giftcards_ordering.php プロジェクト: hnzhang/scrape
    $Special_Messages = $tempplateInfo[0];
    $PickupOptions = $tempplateInfo[1];
    $Order_Deadline = $tempplateInfo[2];
    $deadline_date = strtotime($Order_Deadline);
    $Order_Deadline_Display = date("M/d/Y", $deadline_date);
    $today = time();
    $deadline_str = date("Y-m-d", $deadline_date);
    $today_str = date("Y-m-d", $today);
    if ($today_str <= $deadline_str) {
        $System_Enabled = true;
        getInventoryInfo();
    } else {
        $System_Enabled = false;
        $Special_Messages = "Order deadline " . $Order_Deadline . " expired, cannot order Anymore. Please wait for next time";
    }
    $Current_Time_Display = getCurrentDateTime();
}
?>

<script>
	var Order_Deadline = "<?php 
echo $Order_Deadline;
?>
";
	var Special_Messages = '<?php 
echo $Special_Messages;
?>
';
	var AccountEmail = "<?php 
echo $AccountEmail;
?>
コード例 #11
0
ファイル: edit.php プロジェクト: sfsergey/knowledgetree
 function do_update()
 {
     $oForm = $this->form_edit();
     $res = $oForm->validate();
     if (!empty($res['errors'])) {
         return $oForm->handleError();
     }
     $data = $res['results'];
     // we need to format these in MDPack format
     // which is a little archaic:
     //
     //  array(
     //      array($oField, $sValue),
     //      array($oField, $sValue),
     //      array($oField, $sValue),
     //  );
     //
     // we do this the "easy" way.
     $doctypeid = $this->oDocument->getDocumentTypeId();
     if ($_REQUEST['new_type']) {
         $oTestType = DocumentType::get($_REQUEST['new_type']);
         if (!PEAR::isError($oTestType)) {
             $doctypeid = $oTestType->getId();
         }
     }
     $fieldsets = KTMetadataUtil::fieldsetsForDocument($this->oDocument, $doctypeid);
     $MDPack = array();
     foreach ($fieldsets as $oFieldset) {
         $fields = $oFieldset->getFields();
         $values = (array) KTUtil::arrayGet($data, 'fieldset_' . $oFieldset->getId());
         foreach ($fields as $oField) {
             $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId());
             // FIXME "null" has strange meanings here.
             if (!is_null($val)) {
                 $MDPack[] = array($oField, $val);
             }
         }
     }
     $this->startTransaction();
     if ($this->oDocument->getDocumentTypeId() != $doctypeid) {
         $this->oDocument->setDocumentTypeId($doctypeid);
     }
     $this->oDocument->setName($data['document_title']);
     $this->oDocument->setLastModifiedDate(getCurrentDateTime());
     $this->oDocument->setModifiedUserId($this->oUser->getId());
     // Update the content version / document version
     global $default;
     if ($default->updateContentVersion) {
         $this->oDocument->startNewContentVersion($this->oUser);
         $this->oDocument->setMinorVersionNumber($this->oDocument->getMinorVersionNumber() + 1);
     } else {
         $this->oDocument->startNewMetadataVersion($this->oUser);
     }
     $res = $this->oDocument->update();
     if (PEAR::isError($res)) {
         $oForm->handleError(sprintf(_kt("Unexpected failure to update document title: %s"), $res->getMessage()));
     }
     $core_res = KTDocumentUtil::saveMetadata($this->oDocument, $MDPack);
     if (PEAR::isError($core_res)) {
         $oForm->handleError(sprintf(_kt("Unexpected validation failure: %s."), $core_res->getMessage()));
     }
     // post-triggers.
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('edit', 'postValidate');
     foreach ($aTriggers as $aTrigger) {
         $sTrigger = $aTrigger[0];
         $oTrigger = new $sTrigger();
         $aInfo = array("document" => $this->oDocument, "aOptions" => $MDPack);
         $oTrigger->setInfo($aInfo);
         $ret = $oTrigger->postValidate();
     }
     $this->commitTransaction();
     // create the document transaction record
     $oDocumentTransaction =& new DocumentTransaction($this->oDocument, _kt('Document metadata updated'), 'ktcore.transactions.update');
     $oDocumentTransaction->create();
     // Check if there are any dynamic conditions / permissions that need to be updated on the document
     // If there are dynamic conditions then update the permissions on the document
     // The dynamic condition test fails unless the changes exists in the DB therefore update permissions after committing the transaction.
     $iPermissionObjectId = $this->oDocument->getPermissionObjectID();
     $dynamicCondition = KTPermissionDynamicCondition::getByPermissionObjectId($iPermissionObjectId);
     if (!PEAR::isError($dynamicCondition) && !empty($dynamicCondition)) {
         $res = KTPermissionUtil::updatePermissionLookup($this->oDocument);
     }
     redirect(KTBrowseUtil::getUrlForDocument($this->oDocument->getId()));
     exit(0);
 }
コード例 #12
0
 function _recordUpgrade($result)
 {
     if (is_null($this->date)) {
         $this->date = getCurrentDateTime();
     }
     if ($this->parent) {
         $parentid = $this->parent->getDescriptor();
     } else {
         $parentid = null;
     }
     $sql = "INSERT INTO upgrades (`id`, `descriptor`, `description`, `date_performed`, `result`, `parent`) VALUES (NULL, '" . $this->getDescriptor() . "', '" . $this->description . "', '" . $this->date . "', '" . $result . "', '" . $parentid . "')";
     $this->dbUtilities->query($sql);
     return true;
 }
コード例 #13
0
 function rename($oFolder, $sNewName, $oUser)
 {
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $sOldName = $oFolder->getName();
     // First, deal with SQL, as it, at least, is guaranteed to be atomic
     $table = "folders";
     if ($oFolder->getId() == 1 || $oFolder->getParentID() == 1) {
         $sOldPath = $oFolder->getName();
         $sNewPath = $sNewName;
     } else {
         $sOldPath = $oFolder->getFullPath();
         $sNewPathDir = !empty($sOldPath) ? dirname($sOldPath) . '/' : '';
         $sNewPath = $sNewPathDir . $sNewName;
     }
     $sQuery = "UPDATE {$table} SET full_path = CONCAT(?, SUBSTRING(full_path FROM ?)) WHERE full_path LIKE ? OR full_path = ?";
     $aParams = array("{$sNewPath}/", mb_strlen(utf8_decode($sOldPath)) + 2, $sOldPath . '/%', $sOldPath);
     $res = DBUtil::runQuery(array($sQuery, $aParams));
     if (PEAR::isError($res)) {
         return $res;
     }
     $table = "documents";
     $sQuery = "UPDATE {$table} SET full_path = CONCAT(?, SUBSTRING(full_path FROM ?)) WHERE full_path LIKE ? OR full_path = ?";
     $res = DBUtil::runQuery(array($sQuery, $aParams));
     if (PEAR::isError($res)) {
         return $res;
     }
     $res = $oStorage->renameFolder($oFolder, $sNewName);
     if (PEAR::isError($res)) {
         return $res;
     }
     $oFolder->setName($sNewName);
     $oFolder->setDescription($sNewName);
     $oFolder->setLastModifiedDate(getCurrentDateTime());
     $oFolder->setModifiedUserId($oUser->getId());
     $res = $oFolder->update();
     $oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $oFolder->getId(), 'comment' => sprintf(_kt("Renamed from \"%s\" to \"%s\""), $sOldName, $sNewName), 'transactionNS' => 'ktcore.transactions.rename', 'userid' => $_SESSION['userID'], 'ip' => Session::getClientIP()));
     if (PEAR::isError($oTransaction)) {
         return $oTransaction;
     }
     Document::clearAllCaches();
     Folder::clearAllCaches();
     return $res;
 }
コード例 #14
0
 function rename($oDocument, $sNewFilename, $oUser)
 {
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $oKTConfig = KTConfig::getSingleton();
     $updateVersion = $oKTConfig->get('tweaks/incrementVersionOnRename', true);
     $iPreviousMetadataVersion = $oDocument->getMetadataVersionId();
     $oOldContentVersion = $oDocument->_oDocumentContentVersion;
     if ($updateVersion) {
         $bSuccess = $oDocument->startNewContentVersion($oUser);
         if (PEAR::isError($bSuccess)) {
             return $bSuccess;
         }
         KTDocumentUtil::copyMetadata($oDocument, $iPreviousMetadataVersion);
     }
     $res = $oStorage->renameDocument($oDocument, $oOldContentVersion, $sNewFilename);
     if (!$res) {
         return PEAR::raiseError(_kt('An error occurred while storing the new file'));
     }
     $oDocument->setLastModifiedDate(getCurrentDateTime());
     $oDocument->setModifiedUserId($oUser->getId());
     if ($updateVersion) {
         // Update version number
         $oDocument->setMinorVersionNumber($oDocument->getMinorVersionNumber() + 1);
     }
     $oDocument->_oDocumentContentVersion->setFilename($sNewFilename);
     $sType = KTMime::getMimeTypeFromFile($sNewFilename);
     $iMimeTypeId = KTMime::getMimeTypeID($sType, $sNewFilename);
     $oDocument->setMimeTypeId($iMimeTypeId);
     $bSuccess = $oDocument->update();
     if ($bSuccess !== true) {
         if (PEAR::isError($bSuccess)) {
             return $bSuccess;
         }
         return PEAR::raiseError(_kt('An error occurred while storing this document in the database'));
     }
     // create the document transaction record
     $oDocumentTransaction = new DocumentTransaction($oDocument, _kt('Document renamed'), 'ktcore.transactions.update');
     $oDocumentTransaction->create();
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('renameDocument', 'postValidate');
     foreach ($aTriggers as $aTrigger) {
         $sTrigger = $aTrigger[0];
         $oTrigger = new $sTrigger();
         $aInfo = array('document' => $oDocument);
         $oTrigger->setInfo($aInfo);
         $ret = $oTrigger->postValidate();
         if (PEAR::isError($ret)) {
             return $ret;
         }
     }
     // fire subscription alerts for the checked in document
     $oSubscriptionEvent = new SubscriptionEvent();
     $oFolder = Folder::get($oDocument->getFolderID());
     $oSubscriptionEvent->ModifyDocument($oDocument, $oFolder);
     return true;
 }
コード例 #15
0
ファイル: KTAssist.php プロジェクト: 5haman/knowledgetree
 function &newNotificationForDocument($oDocument, $oUser, $oActor, $sSubject, $sDetails)
 {
     $aInfo = array();
     $aInfo['sData1'] = $sSubject;
     $aInfo['sText1'] = $sDetails;
     $aInfo['iData1'] = $oDocument->getId();
     $aInfo['iData2'] = $oActor->getId();
     $aInfo['sType'] = 'ktcore/assist';
     $aInfo['dCreationDate'] = getCurrentDateTime();
     $aInfo['iUserId'] = $oUser->getId();
     $aInfo['sLabel'] = $oDocument->getName();
     $oNotification = KTNotification::createFromArray($aInfo);
     $handler = new KTAssistNotification();
     if ($oUser->getEmailNotification() && strlen($oUser->getEmail()) > 0) {
         $emailContent = $handler->handleNotification($oNotification);
         $emailSubject = sprintf(_kt('Assistance request: %s'), $oDocument->getName());
         $oEmail = new EmailAlert($oUser->getEmail(), $emailSubject, $emailContent);
         $oEmail->send();
     }
     return $oNotification;
 }
コード例 #16
0
 private function createDBDataSource($filename, $options, $subdir, $file_path)
 {
     global $session, $sql;
     $query = "INSERT INTO datasources (created_at, updated_at, user_id, name, data_path, file_name, `headers`, `lines`)\n\t\t\t\t  VALUES(?, NOW(), ?, ?, ?, ?, ?, ?)";
     $stmt = $sql->link->prepare($query);
     if (!$stmt) {
         die('Invalid query: ' . $sql->link->error);
     } else {
         $csv = new parseCSV();
         $realUserPath = realpath($file_path);
         if (filesize($realUserPath) > 0) {
             $csv->parse($realUserPath, 0, 10000);
             // At max 10000 lines.
             $csvDataRows = $csv->unparse($csv->data, $csv->titles, null, null, null, true);
         } else {
             $csvDataRows = array(array(""));
         }
         $lines = count($csvDataRows) - 1;
         $headers = json_encode($csv->titles);
         $subdirSQL = $options['upload_url'] . $subdir;
         $time = getCurrentDateTime();
         $userID = $this->session->get_user_var('id');
         $stmt->bind_param('sissssi', $time, $userID, $filename, $subdirSQL, $filename, $headers, $lines);
         $resultFromExec = $stmt->execute();
         if ($resultFromExec) {
             $affectedRows = $stmt->affected_rows;
         }
         /* free result */
         $stmt->free_result();
         $stmt->close();
     }
     return array("lines" => $lines, "headers" => implode(", ", array_filter($csv->titles)));
 }
コード例 #17
0
ファイル: edit.php プロジェクト: 5haman/knowledgetree
 function do_update()
 {
     $oForm = $this->form_edit();
     $res = $oForm->validate();
     if (!empty($res['errors'])) {
         return $oForm->handleError();
     }
     $data = $res['results'];
     // we need to format these in MDPack format
     // which is a little archaic:
     //
     //  array(
     //      array($oField, $sValue),
     //      array($oField, $sValue),
     //      array($oField, $sValue),
     //  );
     //
     // we do this the "easy" way.
     $doctypeid = $this->oDocument->getDocumentTypeId();
     if ($_REQUEST['new_type']) {
         $oTestType = DocumentType::get($_REQUEST['new_type']);
         if (!PEAR::isError($oTestType)) {
             $doctypeid = $oTestType->getId();
         }
     }
     $fieldsets = KTMetadataUtil::fieldsetsForDocument($this->oDocument, $doctypeid);
     $MDPack = array();
     foreach ($fieldsets as $oFieldset) {
         $fields = $oFieldset->getFields();
         $values = (array) KTUtil::arrayGet($data, 'fieldset_' . $oFieldset->getId());
         foreach ($fields as $oField) {
             $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId());
             // for html fields we want to do some stripping :)
             if ($oField->getIsHTML()) {
                 // NOTE this works great...once the text is saved a first time
                 //      but the first time the <script> tags come through encoded, so decode first
                 // HOWEVER html_entity_decode decodes too much (e.g. &nbsp; - which causes a DB error for some reason)!  use this instead
                 // NOTE I considered a preg_replace_callback but str_replace is probably more efficient in this case as we only have
                 //      two symbols to replace
                 $val = str_replace('&lt;', '<', $val);
                 $val = str_replace('&gt;', '>', $val);
                 //$val = preg_replace_callback('/&lt;([^&]*)&gt;/', create_function('$matches', 'return "<" . $matches[1] . ">";'), $val);
                 // in case of script which does not yet contain <!-- //--> around the actual code (i.e. first submission again)
                 // these will not be correctly removed by strip_tags
                 $val = preg_replace('/<script[^>]*>([^<]*)<\\/script>/', '', $val);
                 // remove any attempts to call an onclick/onmouseover/onwhatever call
                 $val = preg_replace_callback('/on[^= ]*=[^; \\/>]*;?"? *\\/? *(>?)/', create_function('$matches', 'if (isset($matches[1])) return $matches[1]; else return null;'), $val);
                 // now strip remaining tags including script tags with code surrounded by <!-- //-->,
                 // which would not be stripped by the previous regex
                 $val = strip_tags($val, '<p><a><b><strong><ol><ul><li><p><br><i><em><u><span>');
                 // remove empty <p> tags?
                 $val = preg_replace('/<p><\\/p>\\r?\\n?/', '', $val);
             }
             if ($oField->getDataType() == "LARGE TEXT" && !is_null($oField->getMaxLength())) {
                 if (strlen(strip_tags($val)) > $oField->getMaxLength()) {
                     $oForm->handleError(sprintf(_kt("Value exceeds max allowed length of %d characters for %s. Current value is %d characters."), $oField->getMaxLength(), $oField->getName(), strlen(strip_tags($val))));
                 }
             }
             // FIXME "null" has strange meanings here.
             if (!is_null($val)) {
                 if (KTPluginUtil::pluginIsActive('inet.multiselect.lookupvalue.plugin') && is_array($val) && $oField->getHasInetLookup()) {
                     $val = join(", ", $val);
                 }
                 $MDPack[] = array($oField, $val);
             }
         }
     }
     $this->startTransaction();
     if ($this->oDocument->getDocumentTypeId() != $doctypeid) {
         $this->oDocument->setDocumentTypeId($doctypeid);
     }
     $this->oDocument->setName($data['document_title']);
     $this->oDocument->setLastModifiedDate(getCurrentDateTime());
     $this->oDocument->setModifiedUserId($this->oUser->getId());
     // Update the content version / document version
     global $default;
     if ($default->updateContentVersion) {
         $this->oDocument->startNewContentVersion($this->oUser);
         $this->oDocument->setMinorVersionNumber($this->oDocument->getMinorVersionNumber() + 1);
     } else {
         $this->oDocument->startNewMetadataVersion($this->oUser);
     }
     $res = $this->oDocument->update();
     if (PEAR::isError($res)) {
         $oForm->handleError(sprintf(_kt("Unexpected failure to update document title: %s"), $res->getMessage()));
     }
     $core_res = KTDocumentUtil::saveMetadata($this->oDocument, $MDPack);
     if (PEAR::isError($core_res)) {
         $oForm->handleError(sprintf(_kt("Unexpected validation failure: %s."), $core_res->getMessage()));
     }
     // post-triggers.
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('edit', 'postValidate');
     foreach ($aTriggers as $aTrigger) {
         $sTrigger = $aTrigger[0];
         $oTrigger = new $sTrigger();
         $aInfo = array("document" => $this->oDocument, "aOptions" => $MDPack);
         $oTrigger->setInfo($aInfo);
         $ret = $oTrigger->postValidate();
     }
     $this->commitTransaction();
     // create the document transaction record
     $oDocumentTransaction =& new DocumentTransaction($this->oDocument, _kt('Document metadata updated'), 'ktcore.transactions.update');
     $oDocumentTransaction->create();
     // Check if there are any dynamic conditions / permissions that need to be updated on the document
     // If there are dynamic conditions then update the permissions on the document
     // The dynamic condition test fails unless the changes exists in the DB therefore update permissions after committing the transaction.
     $iPermissionObjectId = $this->oDocument->getPermissionObjectID();
     $dynamicCondition = KTPermissionDynamicCondition::getByPermissionObjectId($iPermissionObjectId);
     if (!PEAR::isError($dynamicCondition) && !empty($dynamicCondition)) {
         $res = KTPermissionUtil::updatePermissionLookup($this->oDocument);
     }
     redirect(KTBrowseUtil::getUrlForDocument($this->oDocument->getId()));
     exit(0);
 }
コード例 #18
0
 /**
  * This updates the metadata on the document. This includes the 'title'.
  *
  * <code>
  * $ktapi = new KTAPI();
  * $session = $ktapi->start_system_session();
  * $document = $ktapi->get_document_by_id($documentid);
  * $metadata = $document->get_metadata();
  * foreach($metadata as $key => $fieldset){
  *     if($fieldset['fieldset'] == 'XYZ'){
  *
  *         foreach($fieldset['fields'] as $k => $field){
  *             if($field['name'] == 'ABC'){
  *                 $metadata[$key][fields][$k]['value'] = 'new value';
  *             }
  *         }
  *     }
  * }
  *
  * $res = $document->update_metadata($metadata);
  * </code>
  *
  * @author KnowledgeTree Team
  * @access public
  * @param array This is an array containing the metadata to be associated with the document.
  * @return void|PEAR_Error Returns nothing on success | a PEAR_Error on failure
  */
 function update_metadata($metadata)
 {
     global $default;
     if (empty($metadata)) {
         return;
     }
     $packed = $this->get_packed_metadata($metadata);
     DBUtil::startTransaction();
     $user = $this->ktapi->get_user();
     $this->document->setLastModifiedDate(getCurrentDateTime());
     $this->document->setModifiedUserId($user->getId());
     // Update the content version / document version
     if ($default->updateContentVersion) {
         $this->document->startNewContentVersion($user);
         $this->document->setMinorVersionNumber($this->document->getMinorVersionNumber() + 1);
     } else {
         $this->document->startNewMetadataVersion($user);
     }
     $res = $this->document->update();
     if (PEAR::isError($res)) {
         DBUtil::rollback();
         return new KTAPI_Error('Unexpected failure updating document', $res);
     }
     $result = KTDocumentUtil::saveMetadata($this->document, $packed, array('novalidate' => true));
     if (is_null($result)) {
         DBUtil::rollback();
         return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR . ': Null result returned but not expected.');
     }
     if (PEAR::isError($result)) {
         DBUtil::rollback();
         return new KTAPI_Error('Unexpected validation failure', $result);
     }
     DBUtil::commit();
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('edit', 'postValidate');
     foreach ($aTriggers as $aTrigger) {
         $sTrigger = $aTrigger[0];
         $oTrigger = new $sTrigger();
         $aInfo = array("document" => $this->document, "aOptions" => $packed);
         $oTrigger->setInfo($aInfo);
         $ret = $oTrigger->postValidate();
     }
 }
コード例 #19
0
 function &newNotificationForDocument($oDocument, $oUser, $oState, $oActor, $sComments)
 {
     $aInfo = array();
     $aInfo['sData1'] = $oState->getName();
     $aInfo['sData2'] = $sComments;
     $aInfo['iData1'] = $oDocument->getId();
     $aInfo['iData2'] = $oActor->getId();
     $aInfo['sType'] = 'ktcore/workflow';
     $aInfo['dCreationDate'] = getCurrentDateTime();
     $aInfo['iUserId'] = $oUser->getId();
     $aInfo['sLabel'] = $oDocument->getName();
     $oNotification = KTNotification::createFromArray($aInfo);
     $handler = new KTWorkflowNotification();
     if ($oUser->getEmailNotification() && strlen($oUser->getEmail()) > 0) {
         $emailContent = $handler->handleNotification($oNotification);
         $emailSubject = sprintf(_kt('Workflow Notification: %s'), $oDocument->getName());
         $oEmail = new EmailAlert($oUser->getEmail(), $emailSubject, $emailContent);
         $oEmail->send();
     }
     return $oNotification;
 }
コード例 #20
0
<?php

require_once 'DataAccess.php';
require_once 'includes/functions.php';
$name = $_POST['name'];
//user info
$id = 1;
$userName = "******";
$email = "*****@*****.**";
$description = $_POST['description'];
$stars = $_POST['stars'];
$latitude = $_POST['latitude'];
$longitude = $_POST['longitude'];
$now = getCurrentDateTime();
$sql = "INSERT INTO problems VALUES (null,'{$name}', '{$id}', '{$userName}', '{$email}','{$description}',null, 'fn','{$now}', 0, '{$now}', 'Active','{$stars}','{$latitude}','{$longitude}')";
$data = new DataAccess('photo');
$result = $data->executeQuery($sql);
$pid = mysql_insert_id();
if (!$result) {
    echo mysql_error();
    return;
}
$data->dispose();
return $pid;
コード例 #21
0
 function create()
 {
     if (is_null($this->iMetadataVersion)) {
         $this->iMetadataVersion = 0;
     }
     if (is_null($this->dVersionCreated)) {
         $this->dVersionCreated = getCurrentDateTime();
     }
     return parent::create();
 }
コード例 #22
0
 function create()
 {
     if (empty($this->dCreated)) {
         $this->dCreated = getCurrentDateTime();
     }
     if (empty($this->dModified)) {
         $this->dModified = getCurrentDateTime();
     }
     if (empty($this->iModifiedUserId)) {
         $this->iModifiedUserId = $this->iCreatorId;
     }
     if (empty($this->iOwnerId)) {
         $this->iOwnerId = $this->iCreatorId;
     }
     if (empty($this->iMetadataVersion)) {
         $this->iMetadataVersion = 0;
     }
     if (empty($this->bIsCheckedOut)) {
         $this->bIsCheckedOut = false;
     }
     if (empty($this->bImmutable)) {
         $this->bImmutable = false;
     }
     $oFolder = Folder::get($this->getFolderId());
     if (PEAR::isError($oFolder) || $oFolder === false || empty($oFolder)) {
         return false;
     }
     $this->iPermissionObjectId = $oFolder->getPermissionObjectId();
     $res = parent::create();
     return $res;
 }
コード例 #23
0
function displayFooter()
{
    ?>
      <span class="text-muted">&copy; Copyright 2014 <a href="">Maggie Ha</a>. All Rights Reserved. 
      <span class="lastModified">Last Modified: <?php 
    getCurrentDateTime();
    ?>
</span></span>
  <?php 
}