public function save($key_id) { $db = new PHPWS_DB('ps_text'); $result = $db->saveObject($this); if (PHPWS_Error::isError($result)) { return $result; } $search = new Search($key_id); $search->addKeywords($this->content); return $search->save(); }
public function save() { PHPWS_Core::initModClass('search', 'Search.php'); if (!$this->id) { $new = true; $this->create_date = time(); } else { $new = false; } $this->last_updated = time(); // If this page has a parent and the order is not set // then increment if (!$this->page_order && $this->parent_page) { $page_order = $this->getLastPage(); if (!PHPWS_Error::logIfError($page_order)) { $this->page_order = $page_order + 1; } else { $this->page_order = 1; } } $db = new PHPWS_DB('ps_page'); if (PHPWS_Error::logIfError($db->saveObject($this))) { return false; } $this->saveKey(); if ($new && Current_User::isRestricted('pagesmith')) { Current_User::giveItemPermission($this->_key); } $search = new Search($this->key_id); $search->resetKeywords(); $search->addKeywords($this->title); PHPWS_Error::logIfError($search->save()); foreach ($this->_sections as $section) { $section->pid = $this->id; PHPWS_Error::logIfError($section->save($this->key_id)); } PHPWS_Cache::remove($this->cacheKey()); }
/** * Versions prior to 1.1.0 didn't have search. This function * plugs in values for all current text sections. */ function pagesmithSearchIndex() { PHPWS_Core::initModClass('search', 'Search.php'); $db = new PHPWS_DB('ps_text'); $db->addColumn('id'); $db->addColumn('content'); $db->addColumn('ps_page.key_id'); $db->addColumn('ps_page.title'); $db->addWhere('ps_text.pid', 'ps_page.id'); $db->addOrder('pid'); $db->addOrder('secname'); $result = $db->select(); if (!empty($result)) { if (PHPWS_Error::logIfError($result)) { return false; } foreach ($result as $pg) { $search = new Search($pg['key_id']); $search->addKeywords($pg['content']); $search->addKeywords($pg['title']); PHPWS_Error::logIfError($search->save()); } } return true; }
function save($save_key = TRUE) { $db = new PHPWS_DB('wiki_pages'); $result = $db->saveObject($this); if (PEAR::isError($result)) { return $result; } if ($save_key) { $result = $this->saveKey(); if (PEAR::isError($result)) { return $result; } $search = new Search($this->key_id); $search->resetKeywords(); $search->addKeywords($this->title); $search->addKeywords($this->pagetext); $search->save(); } }
public static function addKeyword($keyword, $key_id) { $search = new Search((int) $key_id); if ($search->_error) { PHPWS_Error::log($search->_error); return; } $search->addKeywords($keyword, FALSE); return $search->save(); }
public function save() { PHPWS_Core::initModClass('search', 'Search.php'); $table = $this->_schedule->getEventTable(); if (!PHPWS_DB::isTable($table)) { return PHPWS_Error::get(CAL_EVENT_TABLE_MISSING, 'calendar', 'Calendar_Event::save'); } $db = new PHPWS_DB($table); $result = $db->saveObject($this); if (PHPWS_Error::isError($result)) { return $result; } elseif (!$this->pid) { // only save the key if the pid is 0 // ie source event not copy if (empty($this->key_id)) { $save_key = true; } else { $save_key = false; } $key = $this->saveKey(); if (PHPWS_Error::isError($key)) { PHPWS_Error::log($key); return false; } if ($save_key) { $db->saveObject($this); } /* save search settings */ $search = new Search($this->key_id); $search->addKeywords($this->summary); $search->addKeywords($this->location); $search->addKeywords($this->description); $search->save(); return true; } }
public function save() { $db = new PHPWS_DB('blog_entries'); if (empty($this->id)) { $this->create_date = time(); if (!$this->publish_date) { $this->publish_date = $this->create_date; } if (Current_User::isLogged()) { $this->author_id = Current_User::getId(); $this->author = Current_User::getDisplayName(); } elseif (empty($this->author)) { $this->author_id = 0; $this->author = dgettext('blog', 'Anonymous'); } } if (Current_User::isLogged()) { $this->updater_id = Current_User::getId(); $this->updater = Current_User::getDisplayName(); } elseif (empty($this->updater)) { $this->updater_id = 0; $this->updater = dgettext('blog', 'Anonymous'); } $this->update_date = time(); if (empty($this->entry)) { $this->entry = ''; } $result = $db->saveObject($this); if (PHPWS_Error::isError($result)) { return $result; } $update = !$this->key_id ? true : false; $this->saveKey(); if ($update) { $db->saveObject($this); } $search = new Search($this->key_id); $search->resetKeywords(); $search->addKeywords($this->title); $search->addKeywords($this->summary); $search->addKeywords($this->entry); $result = $search->save(); if (PHPWS_Error::isError($result)) { return $result; } return $this->id; }