function testRemovePage() { $this->CI->load->model('script'); $script = new Script($this->DBI); $script->setKey(1); $script->retrieve(); $this->assertTrue(count($script->pages->getPageKeys()) === 2, 'Test page group retrieves as expected'); }
/** * Takes a request for a image in scriptNum-pageNum.jpg format - to allow caching */ protected function page() { $this->load->model('script'); $script = new Script(); $imageFileRequested = $this->uri->segment(4); $splitAroundPipe = explode('-', $imageFileRequested); $scripNum = $splitAroundPipe[0]; $splitOnFullstop = explode('.', $splitAroundPipe[1]); $pageNum = $splitOnFullstop[0]; $script->retrieve($scripNum); $pageFile = $script->pages->getPageKeyAt((int) $pageNum); $this->_outputPage($pageFile); }
/** * * Takes a request for a image in "scriptNum-pageNum.jpg" format - to allow caching; Modified method for demo.. * Modified - enforced white list for demo * @param "$scriptNum-$pageNum.jpg" in 4th url segment */ public function page() { $this->load->model('script'); $script = new Script(); // CHECK THIS IS CORRECT FOR THE CURRENT CONTROLLER LOCATION $imageFileRequested = $this->uri->segment(3); $splitAroundPipe = explode('-', $imageFileRequested); $scripNum = $splitAroundPipe[0]; $scripNum = 32; $splitOnFullstop = explode('.', $splitAroundPipe[1]); $pageNum = $splitOnFullstop[0]; $script->retrieve($scripNum); $pageFile = $script->pages->getPageKeyAt((int) $pageNum); $this->_outputPage($pageFile); }
function testEmptyStoring() { $this->CI->load->model('mark'); $this->CI->load->model('script'); // set script's status to marked $script = new Script(); $script->setKey(1); $script->retrieve(); $pageKeyOriginal = $script->pages->getPageKeys(); $script = new Script(); $script->setKey(1); $script->marked(); $script->update(); $script = new Script(); $script->setKey(1); $script->retrieve(); $this->assertTrue($pageKeyOriginal === $script->pages->getPageKeys(), 'Ensure updating other values doesn\'t over-write pageKeys'); $script->pages->addPage(1, 'fourx', 'old'); $script->update(); $script = new Script(); $script->setKey(1); $script->retrieve(); $this->assertTrue(count($script->pages->getPageKeys()), 'Ensure can add pageKeys'); }
/** * Gets the user's unpaid script if possible, and returns it, or returns a new script * @return $script - new or active script from db */ private function _activeScriptOrNew() { $this->load->model('script'); $script = new Script(); // Does the user have an unpaid script? if ($activeScriptKey = $script->getUnpaidScript($this->session->userdata('email'))) { // if so, then load and retrieve it $script->setKey($activeScriptKey); $script->retrieve(); } else { // No unpaid script; we need to create one $script->createNewScriptFor($this->session->userdata('email')); $script->retrieve(); } return $script; }
private function _scriptAuthCheck($scriptNum, Script $script = null) { if (!$script) { $this->load->model('script'); $script = new Script(); } $script->retrieve($scriptNum); // is the script this user's? if ($script->get('email') === $this->_getUser()) { return true; } return false; }