function convertToPage(&$logged_user, &$error) { db_begin_work(); $page = new Page(); $page->setProjectId($this->getProjectId()); $page->setName($this->getName()); $body = $this->getBody(); if (empty($body)) { $body = 'page Content missing'; } $page->setBody($body); $page->setState($this->getState()); $page->setVisibility($this->getVisibility()); $page->setPriority($this->getPriority()); $page->setCommentsCount($this->getCommentsCount()); $page->setIsLocked($this->getIsLocked()); $page->setCreatedById($logged_user->getId()); $page->setCreatedByName($logged_user->getName()); $page->setCreatedByEmail($logged_user->getEmail()); $save = $page->save(); if ($save && !is_error($save)) { db_commit(); $page->ready(); $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $query = "update healingcrystals_project_objects set parent_id='" . $page->getId() . "', parent_type='Page' where parent_id='" . $this->getId() . "' and project_id='" . $this->getProjectId() . "' and type in ('Comment', 'Task')"; mysql_query($query); $query = "update healingcrystals_project_objects set parent_id=null, parent_type=null where parent_id='" . $this->getId() . "' and project_id='" . $this->getProjectId() . "' and type not in ('Comment', 'Task')"; mysql_query($query); $query = "select * from healingcrystals_assignments where object_id='" . $this->getId() . "'"; $result = mysql_query($query); while ($entry = mysql_fetch_assoc($result)) { $query = "insert into healingcrystals_assignments (user_id, object_id, is_owner) values ('" . $entry['user_id'] . "', '" . $page->getId() . "', '" . $entry['is_owner'] . "')"; mysql_query($query); } $query = "select * from healingcrystals_project_object_categories where object_id='" . $this->getId() . "'"; $result = mysql_query($query); while ($entry = mysql_fetch_assoc($result)) { $query = "insert ignore into healingcrystals_project_object_categories (object_id, category_id) values ('" . $page->getId() . "', '" . $entry['category_id'] . "')"; mysql_query($query); } mysql_close($link); $this->moveToTrash(); return $page->getId(); } else { db_rollback(); $error = $save; return ''; } }