protected function _insert() { if (empty($this->guid)) { $guidMan = new Kutu_Core_Guid(); $this->guid = $guidMan->generateGuid(); } }
protected function _insert() { //add your custom logic here if (empty($this->guid)) { $guidMan = new Kutu_Core_Guid(); $this->guid = $guidMan->generateGuid(); } if (!empty($this->shortTitle)) { $sTitleLower = strtolower($this->shortTitle); $sTitleLower = preg_replace("/[^a-zA-Z0-9 s]/", "", $sTitleLower); $sTitleLower = str_replace(' ', '-', $sTitleLower); $this->shortTitle = $sTitleLower; } $today = date('Y-m-d H:i:s'); if (empty($this->createdDate) || $this->createdDate == '0000-00-00 00:00:00') { $this->createdDate = $today; } if (empty($this->modifiedDate) || $this->modifiedDate == '0000-00-00 00:00:00') { $this->modifiedDate = $today; } $this->deletedDate = '0000-00-00 00:00:00'; if (empty($this->createdBy)) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $this->createdBy = $auth->getIdentity()->username; } else { $this->createdBy = ''; } } if (empty($this->modifiedBy)) { $this->modifiedBy = $this->createdBy; } }
/** * _writeConfirmIndividualEmail * @return JSON */ function _writeForgotPassword($mailcontent, $username, $email) { $obj = new Kutu_Crypt_Password(); $generateGuid = new Kutu_Core_Guid(); $newPassword = $generateGuid->generateGuid(); $mailcontent = str_replace('$fullname', $username, $mailcontent); $mailcontent = str_replace('$password', $newPassword, $mailcontent); $mail_body = $mailcontent; // parse ini_file $config = new Zend_Config_Ini(KUTU_ROOT_DIR . '/application/configs/mail.ini', 'mail'); $mailAttempt = $this->add_mail($config->mail->sender->support->email, $email, $username, 'Bantuan Hukumonline', $mail_body); // try to save mail before send if ($mailAttempt) { $sendAttempt = $this->send_mail(); if ($sendAttempt) { // update user password $tblUser = new Kutu_Core_Orm_Table_User(); $tblUser->update(array('password' => $obj->encryptPassword($newPassword)), "username='******'"); // send confirm to client echo "Please check your email at {$email}!"; } else { echo "Error saving mail DB!"; } } else { echo "Email not provided!"; } }
public function insert(array $data) { if (empty($data['guid'])) { $guidMan = new Kutu_Core_Guid(); $data['guid'] = $guidMan->generateGuid(); } return parent::insert($data); }
function ajaxActionRenderer($url) { Zend_Loader::loadClass("Kutu_Core_Guid"); $o = new Kutu_Core_Guid(); $guid = $o->generateGuid('ajact'); $s = "\n\t\t<div id='out{$guid}'></div>\n\t\t<div id='progress{$guid}'>Loading...</div>\n\t\t\n\t\t\t<script type='text/javascript'>\n\t\t\t\$(document).ready(function() \n\t\t\t//setTimeout(function()\n\t\t\t{ \n\t\t\t\t \$.ajax({\n\t\t\t\t type: 'POST',\n\t\t\t\t url: '{$url}',\n\t\t\t\t beforeSend: function()\n\t\t\t\t {\n\t\t\t\t \t\t\$('#progress{$guid}').show();\n\t\t\t\t },\n\t\t\t\t success: function(msg){\n\t\t\t\t \$('#out{$guid}').html(msg);\n\t\t\t\t \$('#progress{$guid}').hide();\n\t\t\t\t }\n\t\t\t\t });\n\t\t\t //}, 50);\n\t\t\t});\n\t\t\t</script>\n\t\t\n\t\t"; return $s; }
public function insert(array $data) { if (empty($data['promotionid'])) { Zend_Loader::loadClass('Kutu_Core_Guid'); $guid = new Kutu_Core_Guid(); $data['promotionid'] = $guid->generateGuid(); } return parent::insert($data); }
public function insert(array $data) { if (empty($data['guid'])) { $guidMan = new Kutu_Core_Guid(); $data['guid'] = $guidMan->generateGuid(); } if (empty($data['createdDate'])) { $data['createdDate'] = date('Y-m-d H:i:s'); } return parent::insert($data); }
function generateFormAnswer($catalogGuid) { $aRenderedAttributes = array(); $aBaseAttributes = array(); $tableCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowsetCatalog = $tableCatalog->find($catalogGuid); $rowCatalog = $rowsetCatalog->current(); $tableProfileAttribute = new Kutu_Core_Orm_Table_ProfileAttribute(); $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $rowCatalog->profileGuid); $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, array('viewOrder ASC')); $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute(); $i = 0; foreach ($rowsetProfileAttribute as $row) { $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($row->attributeGuid); $rowAttribute = $row->findParentRow('Kutu_Core_Orm_Table_Attribute'); if (isset($rowCatalogAttribute->value)) { $attributeValue = $rowCatalogAttribute->value; } else { $attributeValue = ''; } if (isset($rowCatalogAttribute->guid)) { $catalogAttributeGuid = $rowCatalogAttribute->guid; } else { $guidMan = new Kutu_Core_Guid(); $catalogAttributeGuid = $guidMan->generateGuid(); } $attributeRenderer = new Kutu_Form_Attribute_Renderer($rowAttribute->guid, $attributeValue, $rowAttribute->type, null, 'clinic', 'clinic_category'); $aRenderedAttributes[$rowAttribute->guid]['description'] = $rowAttribute->description; $aRenderedAttributes[$rowAttribute->guid]['form'] = $attributeRenderer->render(); $i++; } $aBaseAttributes['guid']['description'] = ''; $aBaseAttributes['guid']['form'] = "<input type='hidden' name='guid' id='guid' value='{$rowCatalog->guid}'>"; // $aBaseAttributes['shortTitle']['description'] = 'shortTitle'; // $aBaseAttributes['shortTitle']['form'] = "<textarea name='shortTitle' id='shortTitle' rows='1'' cols='50'>$rowCatalog->shortTitle</textarea>"; $aBaseAttributes['profileGuid']['description'] = ''; $aBaseAttributes['profileGuid']['form'] = "<input type='hidden' name='profileGuid' id='profileGuid' value='{$rowCatalog->profileGuid}'>"; $aBaseAttributes['profileGuid']['description'] = 'Sender'; $aBaseAttributes['profileGuid']['form'] = "{$rowCatalog->createdBy}"; // $s = '<input type="Text" id="publishedDate" maxlength="25" size="25" name="publishedDate" value="'.$rowCatalog->publishedDate.'"><a href="javascript:NewCal(\'publishedDate\',\'yyyymmdd\',true,24)"><img src="'.KUTU_ROOT_URL.'/mix_lib/extjs/resources/images/default/custom/img.gif" width="16" height="16" border="0" alt="Pick a date"></a>'; // $aBaseAttributes['publishedDate']['description'] = 'Published Date'; // $aBaseAttributes['publishedDate']['form'] = $s; // $n = '<input type="Text" id="expiredDate" maxlength="25" size="25" name="expiredDate" value="'.$rowCatalog->expiredDate.'"><a href="javascript:NewCal(\'expiredDate\',\'yyyymmdd\',true,24)"><img src="'.KUTU_ROOT_URL.'/mix_lib/extjs/resources/images/default/custom/img.gif" width="16" height="16" border="0" alt="Pick a date"></a>'; // $aBaseAttributes['expiredDate']['description'] = 'Expired Date'; // $aBaseAttributes['expiredDate']['form'] = $n; $aBaseAttributes['status']['description'] = ''; $aBaseAttributes['status']['form'] = "<input type='hidden' name='status' id='status' value='{$rowCatalog->status}'>"; $aReturn = array(); $aReturn['baseForm'] = $aBaseAttributes; $aReturn['attributeForm'] = $aRenderedAttributes; return $aReturn; }
protected function _insert() { //add your custom logic here //must set the new PATH here if (empty($this->guid)) { $guidMan = new Kutu_Core_Guid(); $this->guid = $guidMan->generateGuid(); } if ($this->parentGuid == 'root') { $this->path = ''; $this->parentGuid = $this->guid; } else { $parentFolder = $this->_getTable()->find($this->parentGuid)->current(); $this->path = $parentFolder->path . $parentFolder->guid . '/'; } }
protected function _insert() { if (empty($this->guid)) { $generateGuid = new Kutu_Core_Guid(); $this->guid = $generateGuid->generateGuid(); } if (empty($this->kopel)) { $num = new Kutu_Core_Number(); $this->kopel = $num->generateNumber(5, true); } $today = date('Y-m-d h:i:s'); if (empty($this->createdDate)) { $this->createdDate = $today; } if (empty($this->updatedDate)) { $this->updatedDate = $today; } $userName = ''; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $userName = $auth->getIdentity()->username; } if (empty($this->createdBy)) { $this->createdBy = $userName; } if (empty($this->updatedBy)) { $this->updatedBy = $userName; } if (empty($this->educationId)) { $this->educationId = 0; } if (empty($this->expenseId)) { $this->expenseId = 0; } if (empty($this->activationDate)) { $this->activationDate = '0000-00-00 00:00:00'; } if (empty($this->paymentId)) { $this->paymentId = 0; } if (empty($this->periodeId)) { $this->periodeId = 1; } if (empty($this->isEmailSent)) { $this->isEmailSent = 'N'; } }
static function create($profileGuid, $folderGuid, $shortTitle = '', $publishedDate = '', $expiredDate = '', $status = '0') { $guidMan = new Kutu_Core_Guid(); $catalog = new Kutu_Core_Model_Catalog(); $catalog->guid = $guidMan->generateGuid(); $catalog->profileGuid = $profileGuid; $catalog->addToFolder($folderGuid); $catalog->shortTitle = $shortTitle; $catalog->publishedDate = $publishedDate ? $publishedDate : date('Y-m-d H:i:s'); $catalog->expiredDate = $expiredDate ? $expiredDate : '0000-00-00 00:00:00'; $catalog->status = $status; $userName = ''; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $userName = $auth->getIdentity()->username; } $catalog->createdBy = $userName; return $catalog; }
protected function _insert() { if (empty($this->guid)) { $generateGuid = new Kutu_Core_Guid(); $this->guid = $generateGuid->generateGuid(); } $today = date('Y-m-d h:i:s'); $this->createdDate = $today; $this->modifiedDate = $today; $userName = ''; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $userName = $auth->getIdentity()->username; $this->createdBy = $userName; $this->modifiedBy = $userName; } else { $this->createdBy = $this->username; $this->modifiedBy = $this->username; } }
public function insert(array $data) { if (empty($data['id'])) { $guidMan = new Kutu_Core_Guid(); $data['id'] = $guidMan->generateGuid(); } $today = date('Y-m-d h:i:s'); $data['createdDate'] = $today; $data['updatedDate'] = $today; $userName = ''; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $userName = $auth->getIdentity()->username; } $data['createdBy'] = $userName; $data['updatedBy'] = $userName; if (empty($data['educationId'])) { $data['educationId'] = 0; } if (empty($data['expenseId'])) { $data['expenseId'] = 0; } if (empty($data['activationDate'])) { $data['activationDate'] = '0000-00-00 00:00:00'; } if (empty($data['paymentId'])) { $data['paymentId'] = 0; } if (empty($data['periodeId'])) { $data['periodeId'] = 1; } if (empty($data['isEmailSent'])) { $data['isEmailSent'] = 'N'; } return parent::insert($data); }
function generateFormEdit($catalogGuid) { $today = date('Y-m-d H:i:s'); Zend_Loader::loadClass('Kutu_Form_Attribute_Renderer'); Zend_Loader::loadClass('Kutu_Core_Orm_Table_ProfileAttribute'); Zend_Loader::loadClass('Kutu_Core_Orm_Table_Catalog'); $aRenderedAttributes = array(); $aBaseAttributes = array(); $tableCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowsetCatalog = $tableCatalog->find($catalogGuid); $rowCatalog = $rowsetCatalog->current(); $tableProfileAttribute = new Kutu_Core_Orm_Table_ProfileAttribute(); $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $rowCatalog->profileGuid); $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, array('viewOrder ASC')); $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute(); $i = 0; foreach ($rowsetProfileAttribute as $row) { $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($row->attributeGuid); $rowAttribute = $row->findParentRow('Kutu_Core_Orm_Table_Attribute'); if (isset($rowCatalogAttribute->value)) { $attributeValue = $rowCatalogAttribute->value; } else { $attributeValue = ''; } if (isset($rowCatalogAttribute->guid)) { $catalogAttributeGuid = $rowCatalogAttribute->guid; } else { Zend_Loader::loadClass('Kutu_Core_Guid'); $guidMan = new Kutu_Core_Guid(); $catalogAttributeGuid = $guidMan->generateGuid(); } if (isset($rowAttribute)) { $attributeRenderer = new Kutu_Form_Attribute_Renderer($rowAttribute->guid, $attributeValue, $rowAttribute->type, null, $rowCatalog->profileGuid); $aRenderedAttributes[$rowAttribute->guid]['description'] = $rowAttribute->description; $aRenderedAttributes[$rowAttribute->guid]['form'] = $attributeRenderer->render(); } $i++; } $aBaseAttributes['guid']['description'] = 'Guid'; $aBaseAttributes['guid']['form'] = $rowCatalog->guid . "<input type='hidden' name='guid' id='guid' value='{$rowCatalog->guid}'>"; //$aBaseAttributes['shortTitle']['description'] = 'shortTitle'; //$aBaseAttributes['shortTitle']['form'] = "<textarea name='shortTitle' id='shortTitle' rows='1'' cols='50'>$rowCatalog->shortTitle</textarea>"; $aBaseAttributes['profileGuid']['description'] = 'Profile'; $aBaseAttributes['profileGuid']['form'] = $rowCatalog->profileGuid . "<input type='hidden' name='profileGuid' id='profileGuid' value='{$rowCatalog->profileGuid}'>"; //TO DO: I don't think we should put category/folder input here in cataloginputgenerator. /*$aBaseAttributes['folderGuid']['description'] = 'Category'; $aBaseAttributes['folderGuid']['form'] = $folderGuid."<input type='hidden' name='folderGuid' id='folderGuid' value='$folderGuid'>";*/ //$aBaseAttributes['publishedDate']['description'] = 'Published Date'; //$aBaseAttributes['publishedDate']['form'] = "<input type='text' name='publishedDate' id='publishedDate' value='$rowCatalog->publishedDate'>"; //$aBaseAttributes['expiredDate']['description'] = 'Expired Date'; //$aBaseAttributes['expiredDate']['form'] = "<input type='text' name='expiredDate' id='expiredDate' value='$rowCatalog->expiredDate'>"; $aBaseAttributes['createdBy']['description'] = 'Created By'; $aBaseAttributes['createdBy']['form'] = $rowCatalog->createdBy; //"<input type='text' name='createdBy' id='createdBy' value='$rowCatalog->createdBy'>"; $aBaseAttributes['modifiedBy']['description'] = 'Modified By'; $aBaseAttributes['modifiedBy']['form'] = $rowCatalog->modifiedBy; //"<input type='text' name='modifiedBy' id='modifiedBy' value='$rowCatalog->modifiedBy'>"; $aBaseAttributes['createdDate']['description'] = 'Created on'; $aBaseAttributes['createdDate']['form'] = $rowCatalog->createdDate . "<input type='hidden' name='createdDate' id='createdDate' value='{$rowCatalog->createdDate}'>"; $aBaseAttributes['modifiedDate']['description'] = 'Last Modified on'; $aBaseAttributes['modifiedDate']['form'] = $rowCatalog->modifiedDate . "<input type='hidden' name='modifiedDate' id='modifiedDate' value='{$today}'>"; $aBaseAttributes['deletedDate']['description'] = 'Deleted on'; $aBaseAttributes['deletedDate']['form'] = $rowCatalog->deletedDate . "<input type='hidden' name='deletedDate' id='deletedDate' value='{$rowCatalog->deletedDate}'>"; $aBaseAttributes['status']['description'] = 'Status'; $aBaseAttributes['price']['description'] = 'Price (in USD)'; $aBaseAttributes['price']['form'] = "<input type='text' name='price' id='price' value='{$rowCatalog->price}'>"; require_once CONFIG_PATH . '/master-status.php'; $statusConfig = MasterStatus::getPublishingStatus(); //$aBaseAttributes['status']['form'] = $statusConfig[$rowCatalog->status]."<input type='hidden' name='status' id='status' value='$rowCatalog->status'>"; $attributeRenderer = new Kutu_Form_Attribute_Renderer('status', $rowCatalog->status, 101); $aBaseAttributes['status']['form'] = $attributeRenderer->render(); $aReturn = array(); $aReturn['baseForm'] = $aBaseAttributes; $aReturn['attributeForm'] = $aRenderedAttributes; return $aReturn; }
public function save($aData) { if (isset($aData['fullname']) && !empty($aData['fullname'])) { $aData['firstname'] = $aData['fullname']; } if (empty($aData['firstname'])) { throw new Zend_Exception('Firstname can not be EMPTY!'); } $tblUser = new Kutu_Core_Orm_Table_User(); $gman = new Kutu_Core_Guid(); $guid = isset($aData['guid']) && !empty($aData['guid']) ? $aData['guid'] : $gman->generateGuid(); //if not empty, there are 2 possibilities $tblUser = new Kutu_Core_Orm_Table_User(); $row = $tblUser->fetchRow("guid='{$guid}'"); if (empty($row)) { if (empty($aData['username'])) { throw new Zend_Exception('Username can not be EMPTY!'); } if (empty($aData['password'])) { throw new Zend_Exception('Password can not be EMPTY!'); } $row = $tblUser->createRow(); if (isset($aData['username']) && !empty($aData['username'])) { //check if username was already taken $username = $aData['username']; $tblUser = new Kutu_Core_Orm_Table_User(); $rowUsername = $tblUser->fetchRow("username='******'"); if ($rowUsername) { throw new Zend_Exception('Username exists'); } $row->username = $aData['username']; } if (isset($aData['password']) && !empty($aData['password'])) { $password = $aData['password']; $crypt = new Kutu_Crypt_Password(); $password = $crypt->encryptPassword($password); $row->password = $password; } } if (isset($aData['firstname'])) { $row->firstname = $aData['firstname']; } if (isset($aData['lastname'])) { $row->lastname = $aData['lastname']; } if (isset($aData['email'])) { $row->email = $aData['email']; } if (isset($aData['bbPin'])) { $row->bbPin = $aData['bbPin']; } if (isset($aData['clientId'])) { $row->clientId = $aData['clientId']; } if (isset($aData['mainAddress'])) { $row->mainAddress = $aData['mainAddress']; } if (isset($aData['city'])) { $row->city = $aData['city']; } if (isset($aData['state'])) { $row->state = $aData['state']; } if (isset($aData['zip'])) { $row->zip = $aData['zip']; } if (isset($aData['phone'])) { $row->phone = $aData['phone']; } if (isset($aData['fax'])) { $row->fax = $aData['fax']; } if (isset($aData['url'])) { $row->url = $aData['url']; } if (isset($aData['countryId'])) { $row->countryId = $aData['countryId']; } if (isset($aData['company'])) { $row->company = $aData['company']; } if (isset($aData['companySizeId'])) { $row->companySizeId = $aData['companySizeId']; } if (isset($aData['jobId'])) { $row->jobId = $aData['jobId']; } if (isset($aData['industryId'])) { $row->industryId = $aData['industryId']; } if (isset($aData['isActive'])) { $row->isActive = $aData['isActive']; } if (isset($aData['registrationDate'])) { $row->registrationDate = $aData['registrationDate']; } if (isset($aData['activationDate'])) { $row->activationDate = $aData['activationDate']; } if (isset($aData['activationCode'])) { $row->activationCode = $aData['activationCode']; } if (isset($aData['expirationDate'])) { $row->expirationDate = $aData['expirationDate']; } $row->save(); return $row; }
public function reIndexCatalog() { gc_enable(); $this->emptyIndex(); $time_start = microtime(true); $solr =& $this->_solr; $log = new Kutu_Log(); $formater = new Kutu_Lib_Formater(); $title = new Kutu_View_Helper_GetCatalogTitle(); // $tbl = new Kutu_Core_Orm_Table_Catalog(); // $rowset = $tbl->fetchAll(); //("profileGuid='kutu_peraturan'"); $query = "SELECT * FROM KutuCatalog"; $results = $this->_conn->query($query); $rowset = $results->fetchAll(PDO::FETCH_OBJ); $documents = array(); $rowCount = count($rowset); for ($iCount = 0; $iCount < $rowCount; $iCount++) { $row = $rowset[$iCount]; // if($iCount == 100) // break; // echo 'urutan: '.$iCount .'<br>'; $nextRow = $rowset[$iCount + 1]; // echo 'current guid: '.$row->guid.' '.'next guid: '.$nextRow->guid.'<br>'; if ($row->modifiedBy !== $row->createdBy) { $modified = '<font color=red>[modifiedBy:<i>' . $row->modifiedBy . '</i>]</font> '; } else { $modified = ''; } echo '<li><span style="font:11px verdana,arial,helvetica,sans-serif;">[urutan:' . $iCount . '] indexing:<font color=green>' . $title->getCatalogTitle($row->guid) . '</font>[current guid: ' . $row->guid . ' ' . 'next guid: ' . $nextRow->guid . '][author:<i>' . $row->createdBy . '</i>] ' . $modified . '[createdDate:<i>' . $formater->get_date($row->createdDate) . '</i>]</span></li>'; $documents[] = $this->_createSolrDocument($row); if ($iCount % 500 == 0) { try { $solr->addDocuments($documents); $solr->commit(); // $solr->optimize(); $documents = array(); } catch (Exception $e) { // echo "Error occured when processing record starting from number: ". ($iCount - 1000) . ' to '.$iCount.' '.$row->guid; $log->err($e->getMessage()); throw new Zend_Exception($e->getMessage()); // echo $e->getMessage().'<br>'; } } flush(); } echo '</ul></div></td></tr></table>'; try { $solr->addDocuments($documents); $solr->commit(); // $solr->optimize(); } catch (Exception $e) { $log->err($e->getMessage()); throw new Zend_Exception($e->getMessage()); // echo $e->getMessage().'<br>'; } $time_end = microtime(true); $time = $time_end - $time_start; // echo'<br>WAKTU EKSEKUSI: '. $time; $log->info("WAKTU EKSEKUSI: " . $time . " indexing catalog " . $iCount . " dari " . $rowCount . " " . $username); echo '<br><br><span style="font:11px verdana,arial,helvetica,sans-serif;color:#00FF00">WAKTU EKSEKUSI: ' . $time . '<br>indexing catalog ' . $iCount . ' dari ' . $rowCount . '</span>'; // log to assetSetting $tblAssetSetting = new Kutu_Core_Orm_Table_AssetSetting(); $rowAsset = $tblAssetSetting->fetchRow("application='INDEX CATALOG'"); if ($rowAsset) { $rowAsset->valueText = "Update {$rowCount} indexing-catalog at " . date("Y-m-d H:i:s") . $username; $rowAsset->valueInt = $rowAsset->valueInt + 1; } else { $gman = new Kutu_Core_Guid(); $catalogGuid = $gman->generateGuid(); $rowAsset = $tblAssetSetting->fetchNew(); $rowAsset->guid = $catalogGuid; $rowAsset->application = "INDEX CATALOG"; $rowAsset->part = "KUTU"; $rowAsset->valueType = "INDEX"; $rowAsset->valueInt = 0; $rowAsset->valueText = $rowCount . " Indexing catalog at " . date("Y-m-d H:i:s") . $username; } $rowAsset->save(); }
function generateFormAdd($catalogGuid, $folderGuid = null) { $aRenderedAttributes = array(); $aBaseAttributes = array(); $tableCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowsetCatalog = $tableCatalog->find($catalogGuid); $rowCatalog = $rowsetCatalog->current(); if (!isset($rowCatalog)) { $tableProfileAttribute = new Kutu_Core_Orm_Table_ProfileAttribute(); $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', 'setting'); $rows = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC'); $i = 0; foreach ($rows as $row) { $rowset = $row->findParentRow('Kutu_Core_Orm_Table_Attribute'); $attributeRenderer = new Kutu_Form_Attribute_Renderer($rowset->guid, null, $rowset->type, null); $aRenderedAttributes[$rowset->guid]['description'] = $rowset->description; $aRenderedAttributes[$rowset->guid]['form'] = $attributeRenderer->render(); $i++; } $aBaseAttributes['profileGuid']['description'] = ''; $aBaseAttributes['profileGuid']['form'] = "<input type='hidden' name='profileGuid' id='profileGuid' value='setting'>"; $aBaseAttributes['folderGuid']['description'] = ''; $aBaseAttributes['folderGuid']['form'] = "<input type='hidden' name='folderGuid' id='folderGuid' value='{$folderGuid}'>"; $aBaseAttributes['status']['description'] = ''; $aBaseAttributes['status']['form'] = "<input type='hidden' name='status' id='status' value='1'>"; } else { $tableProfileAttributes = new Kutu_Core_Orm_Table_ProfileAttribute(); $where = $tableProfileAttributes->getAdapter()->quoteInto('profileGuid=?', $rowCatalog->profileGuid); $rowsetProfileAttributes = $tableProfileAttributes->fetchAll($where, array('viewOrder ASC')); $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute(); $i = 0; foreach ($rowsetProfileAttributes as $row) { $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($row->attributeGuid); $rowAttribute = $row->findParentRow('Kutu_Core_Orm_Table_Attribute'); if (isset($rowCatalogAttribute->value)) { $attributeValue = $rowCatalogAttribute->value; } else { $attributeValue = ''; } if (isset($rowCatalogAttribute->guid)) { $catalogAttributeGuid = $rowCatalogAttribute->guid; } else { $guidMan = new Kutu_Core_Guid(); $catalogAttributeGuid = $guidMan->generateGuid(); } $attributeRenderer = new Kutu_Form_Attribute_Renderer($rowAttribute->guid, $attributeValue, $rowAttribute->type, null); $aRenderedAttributes[$rowAttribute->guid]['description'] = $rowAttribute->description; $aRenderedAttributes[$rowAttribute->guid]['form'] = $attributeRenderer->render(); $i++; } $aBaseAttributes['guid']['description'] = ''; $aBaseAttributes['guid']['form'] = "<input type='hidden' name='guid' id='guid' value='{$rowCatalog->guid}'>"; $aBaseAttributes['profileGuid']['description'] = ''; $aBaseAttributes['profileGuid']['form'] = "<input type='hidden' name='profileGuid' id='profileGuid' value='{$rowCatalog->profileGuid}'>"; $aBaseAttributes['status']['description'] = ''; $aBaseAttributes['status']['form'] = "<input type='hidden' name='status' id='status' value='1'>"; } $aReturn = array(); $aReturn['baseForm'] = $aBaseAttributes; $aReturn['attributeForm'] = $aRenderedAttributes; return $aReturn; }
public function uploadFile($aDataCatalog, $relatedGuid) { // must have row catalog with profile Kutu_Doc. See Kutu_Core_Orm_Table_Row_Catalog on how to create a row of catalog. if ($aDataCatalog['profileGuid'] != 'kutu_doc') { throw new Zend_Exception('Profile does not match profile for FILE'); } $aDataCatalog['fixedTitle'] = $aDataCatalog['fixedTitle'] ? $aDataCatalog['fixedTitle'] : 'No-Title'; if (empty($relatedGuid)) { throw new Zend_Exception('No RELATED GUID specified!'); } //get uploaded file data $registry = Zend_Registry::getInstance(); $files = $registry->get('files'); ///foreach ($files as $file){} if (isset($files['uploadedFile'])) { $file = $files['uploadedFile']; if (isset($files['uploadedFile']['name']) && !empty($files['uploadedFile']['name'])) { $aDataCatalog['docSystemName'] = str_replace(array(' ', '(', ')'), '_', $file['name']); //die($aDataCatalog['docSystemName']); $aDataCatalog['docOriginalName'] = $file['name']; $aDataCatalog['docSize'] = $file['size']; $aDataCatalog['docMimeType'] = $file['type']; } } else { throw new Zend_Exception('No File was uploaded.'); } if (isset($files['uploadedFile'])) { if (isset($files['uploadedFile']['name']) && !empty($files['uploadedFile']['name'])) { $sDir = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $relatedGuid; if (is_dir($sDir)) { //if enters here, you may save the files move_uploaded_file($file['tmp_name'], $sDir . DIRECTORY_SEPARATOR . $aDataCatalog['docSystemName']); //echo 'dir'; } else { if (mkdir($sDir)) { //if enters here, let's continue saving the file. move_uploaded_file($file['tmp_name'], $sDir . DIRECTORY_SEPARATOR . $aDataCatalog['docSystemName']); } else { //if enters here, then it means, you CAN'T create the folder, maybe because the safe mode is ON. //save the file in the upload/files folder move_uploaded_file($file['tmp_name'], KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $aDataCatalog['docSystemName']); } } } } $gman = new Kutu_Core_Guid(); $catalogGuid = $gman->generateGuid(); $aDataCatalog['guid'] = $catalogGuid; $this->relateTo($catalogGuid, $relatedGuid, 'RELATED_FILE'); $catalogGuid = $this->save($aDataCatalog); //print_r($aDataCatalog); //die(); //reindex catalog or parentCatalog or flag parent catalog as "need to be indexed" by setting isIndexed=0 $indexingEngine = Kutu_Search::manager(); $indexingEngine->indexCatalog($relatedGuid); }
function generateGuid($prefix = null) { $o = new Kutu_Core_Guid(); return $o->generateGuid($prefix); }