/** * open database connection, select database and return link identifier or FALSE * @return resource|bool link identifier or FALSE in case of any error */ function connect() { $this->_log->trace("opening db connection (host=" . $this->host . ", user="******")"); $db_link = @mysql_connect($this->host, $this->user, $this->passwd); if (!$db_link) { $this->error_str = "unable to connect to database (host=" . $this->host . ", user="******")"; $this->_log->error($this->error_str); return FALSE; } $succes = mysql_select_db($this->database, $db_link); if (!$succes) { $this->error_str = "unable to select database (db=" . $this->database . ")"; $this->_log->error($this->error_str); return FALSE; } return $db_link; }
public function eventFeedPreloadAction() { $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); $editable = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); $calendar_interval = Application_Model_Preference::GetCalendarTimeScale(); Logging::info($calendar_interval); if ($calendar_interval == "agendaDay") { list($start, $end) = Application_Model_Show::getStartEndCurrentDayView(); } else { if ($calendar_interval == "agendaWeek") { list($start, $end) = Application_Model_Show::getStartEndCurrentWeekView(); } else { if ($calendar_interval == "month") { list($start, $end) = Application_Model_Show::getStartEndCurrentMonthView(); } else { Logging::error("Invalid Calendar Interval '{$calendar_interval}'"); } } } $events =& Application_Model_Show::getFullCalendarEvents($start, $end, $editable); $this->view->events = $events; }
/** * log given log message and set error string and error message string * @param string log_message human readable log message for this error * @param string error_message error message for user * @return void */ function _handle_error($log_message, $error_message) { if (strlen($log_message) > 0) { $this->_log->error($log_message); $this->error_log_str = $log_message; } else { $this->error_log_str = ""; } if (strlen($this->_database->get_error_str()) > 0) { $this->_log->error("database error: " . $this->_database->get_error_str()); $this->error_str = $this->_database->get_error_str(); } else { $this->error_str = ""; } $this->error_message_str = $error_message; }
/** * Delete stored virtual file * * @param boolean $p_deleteFile * */ public function delete() { $filepath = $this->getFilePath(); // Check if the file is scheduled to be played in the future if (Application_Model_Schedule::IsFileScheduledInTheFuture($this->getId())) { throw new DeleteScheduledFileException(); } $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); if (!$isAdminOrPM && $this->getFileOwnerId() != $user->getId()) { throw new FileNoPermissionException(); } $music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory()); $type = $music_dir->getType(); if (file_exists($filepath) && $type == "stor") { $data = array("filepath" => $filepath, "delete" => 1); try { Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data); } catch (Exception $e) { Logging::error($e->getMessage()); return; } } // set hidden flag to true $this->_file->setDbHidden(true); $this->_file->save(); // need to explicitly update any playlist's and block's length // that contains the file getting deleted $fileId = $this->_file->getDbId(); $plRows = CcPlaylistcontentsQuery::create()->filterByDbFileId()->find(); foreach ($plRows as $row) { $pl = CcPlaylistQuery::create()->filterByDbId($row->getDbPlaylistId($fileId))->findOne(); $pl->setDbLength($pl->computeDbLength(Propel::getConnection(CcPlaylistPeer::DATABASE_NAME))); $pl->save(); } $blRows = CcBlockcontentsQuery::create()->filterByDbFileId($fileId)->find(); foreach ($blRows as $row) { $bl = CcBlockQuery::create()->filterByDbId($row->getDbBlockId())->findOne(); $bl->setDbLength($bl->computeDbLength(Propel::getConnection(CcBlockPeer::DATABASE_NAME))); $bl->save(); } }