public function testPageUrlUnique() { // Create page with url that exists $page = new Page(); $page->setAttributes(array('category_id' => '1', 'publish_date' => '2011-12-01 18:55:06', 'status' => 'published', 'title' => 'Page Test Urls Unique', 'url' => 'page-1')); $this->assertTrue($page->save()); $this->assertEquals('page-1' . '-' . date('YmdHis'), $page->url); }
public function actionAdmin() { $model = new Page('search'); $model->unsetAttributes(); if (isset($_GET['Page'])) { $model->setAttributes($_GET['Page']); } $this->render('admin', array('model' => $model)); }
function goto_tasks_page_for_user() { $user = Users::findById($this->request->getId('selected_user_id')); $page_title = $user->getName() . ' - Task List'; $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME, $link); $query = "select id from healingcrystals_project_objects where type='Page' and project_id='" . TASK_LIST_PROJECT_ID . "' and name='" . mysql_real_escape_string($page_title) . "'"; $result = mysql_query($query, $link); if (mysql_num_rows($result)) { $info = mysql_fetch_assoc($result); $this->redirectToUrl(assemble_url('project_page', array('project_id' => TASK_LIST_PROJECT_ID, 'page_id' => $info['id']))); } else { $query = "select id from healingcrystals_project_objects where type='Category' and module='pages' and project_id='" . TASK_LIST_PROJECT_ID . "' and name='General'"; $page_category = mysql_query($query); $page_category_info = mysql_fetch_assoc($page_category); $page_data = array('type' => 'Page', 'module' => 'pages', 'visibility' => VISIBILITY_NORMAL, 'name' => $page_title, 'body' => 'Auto-generated Task List Page', 'integer_field_1' => '1'); db_begin_work(); $this->active_page = new Page(); $this->active_page->setAttributes($page_data); $this->active_page->setProjectId(TASK_LIST_PROJECT_ID); $this->active_page->setCreatedBy($this->logged_user); $this->active_page->setState(STATE_VISIBLE); $this->active_page->setParentId($page_category_info['id']); $save = $this->active_page->save(); if ($save && !is_error($save)) { //$subscribers = array($this->logged_user->getId()); //if(!in_array($this->active_project->getLeaderId(), $subscribers)) { // $subscribers[] = $this->active_project->getLeaderId(); //} //Subscriptions::subscribeUsers($subscribers, $this->active_page); db_commit(); $this->active_page->ready(); $query = "select * from healingcrystals_project_users where user_id='" . $user->getId() . "' and project_id='" . TASK_LIST_PROJECT_ID . "'"; $result = mysql_query($query, $link); if (!mysql_num_rows($result)) { //mysql_query("insert into healingcrystals_project_users (user_id, project_id, role_id, permissions) values ('" . $user->getId() . "', '" . TASK_LIST_PROJECT_ID . "', '" . $user->getRoleId() . "', 'N;')"); mysql_query("insert into healingcrystals_project_users (user_id, project_id, role_id, permissions) values ('" . $user->getId() . "', '" . TASK_LIST_PROJECT_ID . "', '7', 'N;')"); } elseif ($user->getRoleId() == '2') { mysql_query("update healingcrystals_project_users set role_id='7' where user_id='" . $user->getId() . "' and project_id='" . TASK_LIST_PROJECT_ID . "'"); } $this->redirectToUrl(assemble_url('project_page', array('project_id' => TASK_LIST_PROJECT_ID, 'page_id' => $this->active_page->getId()))); } else { db_rollback(); //$save .= 'rollback'; } } mysql_close($link); $this->smarty->assign(array('user' => $user, 'project' => $this->active_project, 'errors' => $save, 'data' => $page_data)); }
public function actionManage() { $page = new Page('search'); $page->unsetAttributes(); $page->type = 'Page'; if (isset($_GET['Page'])) { $page->setAttributes($_GET['Page']); } $this->render('manage', array('page' => $page)); }
/** * Manages all models. * * @return void */ public function actionIndex() { $model = new Page('search'); $model->unsetAttributes(); $model->setAttributes(Yii::app()->getRequest()->getParam('Page', [])); $this->render('index', ['model' => $model, 'pages' => Page::model()->getAllPagesList()]); }
function getTaskPageIdForUser($user_id) { $page_id = ''; $user = new User($user_id); $name = $user->getName(); list($first_name, $last_name) = explode(' ', $name); $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME, $link); $page_title = $name . ' - Task List'; $query2 = "select id from healingcrystals_project_objects where type='Page' and project_id='" . TASK_LIST_PROJECT_ID . "' and name='" . mysql_real_escape_string($page_title) . "'"; $result2 = mysql_query($query2, $link); if (mysql_num_rows($result2)) { $info2 = mysql_fetch_assoc($result2); $page_id = $info2['id']; } else { $query3 = "select id from healingcrystals_project_objects where type='Category' and module='pages' and project_id='" . TASK_LIST_PROJECT_ID . "' and name='General'"; $page_category = mysql_query($query3, $link); $page_category_info = mysql_fetch_assoc($page_category); $category_id = $page_category_info['id']; $page_data = array('type' => 'Page', 'module' => 'pages', 'visibility' => VISIBILITY_NORMAL, 'name' => $page_title, 'body' => 'Auto-generated Task List Page', 'integer_field_1' => '1'); $page = new Page(); $page->setAttributes($page_data); $page->setProjectId(TASK_LIST_PROJECT_ID); $page->setCreatedBy($user); $page->setState(STATE_VISIBLE); $page->setParentId($category_id); $page->save(); $page->ready(); $page_id = $page->getId(); $query = "select * from healingcrystals_project_users where user_id='" . $user_id . "' and project_id='" . TASK_LIST_PROJECT_ID . "'"; $result = mysql_query($query, $link); if (!mysql_num_rows($result)) { mysql_query("insert into healingcrystals_project_users (user_id, project_id, role_id, permissions) values ('" . $user_id . "', '" . TASK_LIST_PROJECT_ID . "', '7', 'N;')"); } elseif ($user->getRoleId() == '2') { mysql_query("update healingcrystals_project_users set role_id='7' where user_id='" . $user_id . "' and project_id='" . TASK_LIST_PROJECT_ID . "'"); } } //mysql_close($link); return $page_id; }
function getPageId(&$incoming_mail, &$project, &$user) { $page_id = ''; list($user_name, ) = explode('-', $incoming_mail->getSubject()); $user_name = trim($user_name); $name_parts = explode(' ', $user_name); list($first_name, $last_name) = $name_parts; $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME, $link); $query = "select id from healingcrystals_users where first_name='" . mysql_real_escape_string($first_name) . "' " . (!empty($last_name) ? " and last_name='" . mysql_real_escape_string($last_name) . "' " : ""); $result = mysql_query($query, $link); if (mysql_num_rows($result)) { $info = mysql_fetch_assoc($result); $user_id = $info['id']; } elseif (strpos($incoming_mail->getSubject(), '}') !== false) { $user_id = substr($incoming_mail->getSubject(), strrpos($incoming_mail->getSubject(), '{') + 1, -1); } if (!empty($user_id)) { $task_meant_for_user = Users::findById($user_id); $page_title = $task_meant_for_user->getName() . ' - Task List'; //echo $page_title . '<br/>'; $query2 = "select id from healingcrystals_project_objects where type='Page' and project_id='" . TASK_LIST_PROJECT_ID . "' and name='" . mysql_real_escape_string($page_title) . "'"; //echo $query2 . '<br/>'; $result2 = mysql_query($query2, $link); if (mysql_num_rows($result2)) { $info2 = mysql_fetch_assoc($result2); $page_id = $info2['id']; } else { $query3 = "select id from healingcrystals_project_objects where type='Category' and module='pages' and project_id='" . TASK_LIST_PROJECT_ID . "' and name='General'"; //echo $query3 . '<br/>'; $page_category = mysql_query($query3, $link); $page_category_info = mysql_fetch_assoc($page_category); $category_id = $page_category_info['id']; //echo $category_id . '<br/>'; $page_data = array('type' => 'Page', 'module' => 'pages', 'visibility' => VISIBILITY_NORMAL, 'name' => $page_title, 'body' => 'Auto-generated Task List Page', 'integer_field_1' => '1'); //print_r($page_data); //db_begin_work(); $page = new Page(); $page->setAttributes($page_data); $page->setProjectId(TASK_LIST_PROJECT_ID); $page->setCreatedBy($user); $page->setState(STATE_VISIBLE); $page->setParentId($category_id); $page->save(); $page->ready(); $page_id = $page->getId(); } $query = "select * from healingcrystals_project_users where user_id='" . $task_meant_for_user->getId() . "' and project_id='" . TASK_LIST_PROJECT_ID . "'"; $result = mysql_query($query, $link); if (!mysql_num_rows($result)) { //mysql_query("insert into healingcrystals_project_users (user_id, project_id, role_id, permissions) values ('" . $user->getId() . "', '" . TASK_LIST_PROJECT_ID . "', '" . $user->getRoleId() . "', 'N;')"); mysql_query("insert into healingcrystals_project_users (user_id, project_id, role_id, permissions) values ('" . $task_meant_for_user->getId() . "', '" . TASK_LIST_PROJECT_ID . "', '7', 'N;')"); } elseif ($user->getRoleId() == '2') { mysql_query("update healingcrystals_project_users set role_id='7' where user_id='" . $task_meant_for_user->getId() . "' and project_id='" . TASK_LIST_PROJECT_ID . "'"); } } mysql_close($link); return $page_id; }