public function insert(array $data)
 {
     require_once 'models/Session.php';
     $data['timestamp_created'] = new Zend_Db_Expr('NOW()');
     $data['created_by'] = Session::getCurrentUserId();
     //don't set is_deleted
     return Zend_Db_Table_Abstract::insert($data);
 }
 public function languageAction()
 {
     require_once 'models/Session.php';
     require_once 'models/table/User.php';
     if ($this->isLoggedIn() and array_key_exists($this->getSanParam('opt'), ITechTranslate::getLanguages())) {
         $user = new User();
         $userRow = $user->find(Session::getCurrentUserId())->current();
         $user->updateLocale($this->getSanParam('opt'), Session::getCurrentUserId());
         $auth = Zend_Auth::getInstance();
         $identity = $auth->getIdentity();
         $identity->locale = $this->getSanParam('opt');
         $auth->getStorage()->write($identity);
         setcookie('locale', $this->getSanParam('opt'), null, Globals::$BASE_PATH);
     }
     $this->_redirect($_SERVER['HTTP_REFERER']);
 }
 /**
  * import training session
  */
 public function importTraining()
 {
     $select = $this->select()->from($this->_name, array('*'))->where("{$this->_name}.id = {$training_id}");
     $row = $this->fetchRow($select);
     $rowDup = $row->toArray();
     unset($rowDup['id']);
     unset($rowDup['uuid']);
     $dupId = $this->insert($rowDup);
     // import other tables now
     $db = $this->getDefaultAdapter();
     // pepfar
     $db->query("\r\n      INSERT INTO training_to_training_pepfar_categories_option\r\n      (id, training_id, training_pepfar_categories_option_id, duration_days, created_by, timestamp_created)\r\n      SELECT 0, {$dupId}, training_pepfar_categories_option_id, duration_days, " . Session::getCurrentUserId() . ", now() " . " FROM training_to_training_pepfar_categories_option\r\n      WHERE training_id = {$training_id}\r\n      ");
     // funding //todo refresher and title and other stuff (maybe?)
     $db->query("\r\n      INSERT INTO training_to_training_funding_option\r\n      (id, training_id, training_funding_option_id, created_by, timestamp_created)\r\n      SELECT 0, {$dupId}, training_funding_option_id, " . Session::getCurrentUserId() . ", now() " . " FROM training_to_training_funding_option\r\n      WHERE training_id = {$training_id}\r\n      ");
     //added June 12,2008 ToddW
     // participants
     $db->query("\r\n      INSERT INTO person_to_training\r\n      (person_id, training_id, created_by, timestamp_created)\r\n      SELECT person_id, {$dupId}," . Session::getCurrentUserId() . ", now() " . " FROM person_to_training\r\n       WHERE training_id = {$training_id}\r\n      ");
     // trainers
     $db->query("\r\n      INSERT INTO training_to_trainer\r\n      (trainer_id, training_id, duration_days, created_by, timestamp_created)\r\n      SELECT trainer_id, {$dupId}, duration_days," . Session::getCurrentUserId() . ", now() " . " FROM training_to_trainer\r\n       WHERE training_id = {$training_id}\r\n      ");
     return $dupId;
 }
 /**
  * Set is_deleted as 0 and return row
  */
 public function undelete($field, $value)
 {
     require_once 'models/Session.php';
     $data['is_deleted'] = 0;
     $data['timestamp_updated'] = new Zend_Db_Expr('NOW()');
     $data['modified_by'] = Session::getCurrentUserId();
     parent::update($data, "{$field}='{$value}'");
     return $this->fetchRow($this->select()->where("{$field}='{$value}'"));
 }