Example #1
0
 /**
  * Constructor
  *
  * @param Pandamp_BeanContext_Decoratable $mixed  The table class to model, or the classname
  * as a string of the model to decorate. The class will then try to
  * load the class and instantiate it with no arguments.
  * @param Pandamp_Filter_Input $filter An optional filter that gets processed before the
  * data is returned. The flter will only be used if teh data is decorated as dto or entity
  * @param boolean $strict if set to false, mising setters for any property available will not
  * throw an exception
  *
  * @throws Exception
  */
 public final function __construct($mixed, Pandamp_Filter_Input $filter = null, $strict = true)
 {
     $this->_filter = $filter;
     $this->_strict = $strict;
     if (is_string($mixed)) {
         Pandamp_BeanContext_Inspector::loadClass($mixed);
         if (!class_exists($mixed)) {
             throw new Exception("Could not find class to decorate \"{$mixed}\".");
         }
         $this->_decoratedModel = new $mixed();
     } else {
         $this->_decoratedModel = $mixed;
     }
     if (!$this->_decoratedModel instanceof Pandamp_BeanContext_Decoratable) {
         throw new Exception("Decorated class is no subclass of \"Pandamp_BeanContext_Decoratable\"");
     }
     $this->_decoratedMethods = $this->_decoratedModel->getDecoratableMethods();
     $this->_entity = $this->_decoratedModel->getRepresentedEntity();
     Pandamp_BeanContext_Inspector::loadClass($this->_entity);
     if (!class_exists($this->_entity)) {
         throw new Exception("Could not find entity \"" . $this->_entity . "\".");
     }
     $refC = new ReflectionClass($this->_entity);
     if (!$refC->implementsInterface('Pandamp_BeanContext')) {
         throw new Exception("Entity \"" . $this->_entity . "\" is not a \"Pandamp_BeanContext\"-class.");
     }
 }
 public function aclconfigAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     $methods = get_class_methods('StudentController');
     $actions = array();
     foreach ($methods as $value) {
         $actions[] = substr("{$value}", 0, strpos($value, 'Action'));
     }
     foreach ($actions as $key => $value) {
         if ($value == null) {
             unset($actions[$key]);
         }
     }
     $db = new Zend_Db_Table();
     $delete2 = 'DELETE FROM `tnp`.`mod_role_resource` WHERE `module_id`=? AND `controller_id`=?';
     $db->getAdapter()->query($delete2, array('tnp', 'student'));
     $delete1 = 'DELETE FROM `tnp`.`mod_action` WHERE `module_id`=? AND `controller_id`=?';
     $db->getAdapter()->query($delete1, array('tnp', 'student'));
     print_r(sizeof($actions));
     $sql = 'INSERT INTO `tnp`.`mod_action`(`module_id`,`controller_id`,`action_id`) VALUES (?,?,?)';
     foreach ($actions as $action) {
         $bind = array('tnp', 'student', $action);
         $db->getAdapter()->query($sql, $bind);
     }
     $sql = 'INSERT INTO `tnp`.`mod_role_resource`(`role_id`,`module_id`,`controller_id`,`action_id`) VALUES (?,?,?,?)';
     foreach ($actions as $action) {
         $bind = array('student', 'tnp', 'student', $action);
         $db->getAdapter()->query($sql, $bind);
     }
 }
Example #3
0
 /**
  * Class constructor
  *
  * @param Zend_Db_Adapter $db   Database adapter instance
  * @param Zend_Db_Table $table 
  * @param array $columnMap
  * @return void
  */
 public function __construct($db, Zend_Db_Table $table, $columnMap = null)
 {
     $info = $table->info();
     parent::__construct($db, $info['schema'] . '.' . $info['name'], $columnMap);
     $this->_db = $db;
     $this->_table = $table;
     $this->_columnMap = $columnMap;
 }
Example #4
0
 public function updateCommentsAd($id, $count)
 {
     $id = (int) $id;
     $table = new Zend_Db_Table('commentsAdCount');
     $sql = "INSERT INTO commentsAdCount   ( id_comment, count ) VALUES  ( ?,? )\n                            ON DUPLICATE KEY UPDATE id_comment = ?, count = ?";
     $values = array("id_comment" => $id, "count" => $count);
     $result = $table->getAdapter()->query($sql, array_merge(array_values($values), array_values($values)));
 }
Example #5
0
 /**
  * (non-PHPdoc)
  * @see models/Sahara/Auth/Sahara_Auth_Session::setup()
  */
 public function setup()
 {
     $table = new Zend_Db_Table('users');
     $record = $table->fetchRow($table->select()->where('name = ?', $this->_authType->getUsername())->where('namespace = ?', $this->_config->institution));
     /* User name exists, so no need to create account. */
     if ($record) {
         return;
     }
     $table->insert(array('name' => $this->_authType->getUsername(), 'namespace' => $this->_config->institution, 'persona' => 'USER'));
 }
Example #6
0
 public function formAction()
 {
     $table = new Zend_Db_Table();
     $table->setOptions(array('name' => 'test'));
     $table->setMetadataCacheInClass(true);
     $data = array('listorder' => '11');
     $table->insert($data);
     Zend_Debug::dump($table);
     die;
 }
Example #7
0
 public static function getLastAccess($classroomId, $data)
 {
     $access = new Zend_Db_Table('content_access');
     $select = $access->select()->where('classroom_id = ?', $classroomId)->order('content_access.id DESC');
     $row = $access->fetchRow($select);
     if ($row) {
         return self::getPositionById($row->content_id, $data);
     }
     return 0;
 }
Example #8
0
 /**
  * Retorna el Rol del usuario actual
  * 
  * @return string
  */
 private function getRol()
 {
     $rolStr = 'guest';
     if ($this->_auth->hasIdentity()) {
         $numRol = $this->_auth->getIdentity()->rol;
         $tablaRol = new Zend_Db_Table('roles');
         $rol = $tablaRol->fetchRow($tablaRol->select()->from($tablaRol)->where('idRol = ?', $numRol));
         $rolStr = $rol['rol'];
     }
     return $rolStr;
 }
Example #9
0
 /**
  * Show table info (DESCRIBE query) for given table
  *
  * @param array $args
  * @return void
  */
 public function info(array $args = array())
 {
     if (empty($args)) {
         Garp_Cli::errorOut('Insufficient arguments');
         Garp_Cli::lineOut('Usage: garp Db info <tablename>');
         return;
     }
     $db = new Zend_Db_Table($args[0]);
     Garp_Cli::lineOut(Zend_Config_Writer_Yaml::encode($db->info()));
     Garp_Cli::lineOut('');
 }
 public function indexAction()
 {
     $queries = (int) $this->getParam('queries', 1);
     $queries = max(1, $queries);
     $queries = min(500, $queries);
     $table = new Zend_Db_Table('World');
     $worlds = array();
     for ($i = 0; $i < $queries; $i += 1) {
         $worlds[] = $table->fetchRow(array('id = ?' => mt_rand(1, 10000)))->toArray();
     }
     $this->_helper->json->sendJson($worlds);
 }
Example #11
0
 public function addAction()
 {
     $form = new Application_Model_ContactForm(array('action' => '/contact/add', 'method' => 'POST'));
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $contact = new Zend_Db_Table('contacts');
             $data = array('name' => $this->_request->getPost('name'), 'email' => $this->_request->getPost('email'), 'type' => $this->_request->getPost('type'));
             $contact->insert($data);
             echo "<p>Contact added!</p>";
         }
     }
     $this->view->form = $form;
 }
Example #12
0
 /**
  * Returns id by name($value) from table
  *
  * @param  string $value
  * @return string
  */
 public function filter($value)
 {
     if ($value === null) {
         return null;
     }
     $select = $this->_table->select()->where($this->_field . ' = ?', $value);
     $row = $this->_table->fetchRow($select);
     if ($row !== null) {
         return $row[reset($this->_table->info(Zend_Db_Table::PRIMARY))];
     } else {
         return null;
     }
 }
Example #13
0
 function getTable($name)
 {
     if (!($result = $this->_cache->load($this->_options[$name]['table']))) {
         $table = new Zend_Db_Table($this->_options[$name]['table']);
         if ($name == 'privilege') {
             $sql = new Zend_Db_Select($table->getDefaultAdapter());
             $sql->from(array('acl' => $this->_options['privilege']['table']), array('acl.ID_PERFIL'))->join(array('r' => $this->_options['resource']['table']), 'acl.ID_MENU=r.ID_MENU', array('r.URL_MENU', 'acl.PERMISO'));
             $result = $table->getAdapter()->fetchAll($sql);
         } else {
             $result = $table->fetchAll();
         }
         $this->_cache->save($result, $this->_options[$name]['table']);
     }
     return $result;
 }
Example #14
0
 private function _init()
 {
     global $logger;
     $oTable = new Zend_Db_Table('path');
     foreach ($oTable->fetchAll($oTable->select())->toArray() as $xt) {
         $this->_path[] = $xt['name'];
     }
     $oTable = new Zend_Db_Table('container');
     $t = array();
     foreach ($oTable->fetchAll($oTable->select())->toArray() as $xt) {
         $t[] = $xt['name'];
     }
     $this->_extensions = implode(',', $t);
     $logger->log('Valid extensions are : ' . $this->_extensions, Zend_Log::DEBUG);
 }
Example #15
0
 public function getTableFields($tableName)
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $columns = $db->query("SELECT menufields FROM main_menu WHERE url = '" . $tableName . "'");
     $columnData = $columns->fetch();
     return $columnData;
 }
Example #16
0
 public function fillgridAction()
 {
     $request = $this->getRequest();
     $valid = $request->getParam('nd');
     if ($valid) {
         $this->grid = $this->_helper->grid();
         $this->grid->sql = Zend_Db_Table::getDefaultAdapter()->select()->from('opac_issue_return', array('acc_no', 'member_id', 'title', 'author', 'edition', 'issue_date', 'return_date', 'isbn_id', 'status', 'issued_by', 'accepted_by'));
         $searchOn = $request->getParam('_search');
         if ($searchOn != 'false') {
             $sarr = $request->getParams();
             foreach ($sarr as $key => $value) {
                 switch ($key) {
                     case 'isbn_id':
                     case 'acc_no':
                     case 'edition':
                     case 'status':
                     case 'member_id':
                     case 'issued_by':
                     case 'accepted_by':
                         $this->grid->sql->where("{$key} = ?", $value);
                         break;
                     case 'title':
                     case 'author':
                     case 'issue_date':
                     case 'return_date':
                         $this->grid->sql->where("{$key} LIKE ?", '%' . $value . '%');
                         break;
                 }
             }
         }
         self::fillgridfinal();
     } else {
         echo '<b>Oops!! </b><br/>No use of peeping like that.. :)';
     }
 }
 public function fillgridAction()
 {
     self::createModel();
     $request = $this->getRequest();
     $valid = $request->getParam('nd');
     if ($request->isXmlHttpRequest() and $valid) {
         $this->grid = $this->_helper->grid();
         $this->grid->setGridparam($request);
         $this->grid->sql = Zend_Db_Table::getDefaultAdapter()->select()->from($this->model->info('name'), array('subject_faculty.subject_code', 'subject_mode_id', 'staff_id', 'subject_department.degree_id', 'department_id', 'department_id', 'subject_department.semester_id'))->joinLeft('subject_department', '(subject_department.subject_code = subject_faculty.subject_code AND subject_department.department_id = subject_faculty.department_id)', array())->where('subject_faculty.department_id = ?', $this->department_id);
         $searchOn = $request->getParam('_search');
         if ($searchOn != 'false') {
             $sarr = $request->getParams();
             foreach ($sarr as $key => $value) {
                 switch ($key) {
                     case 'staff_id':
                         $this->grid->sql->where("{$key} LIKE ?", '%' . $value . '%');
                         break;
                     case 'subject_code':
                         $this->grid->sql->where("subject_faculty.subject_code LIKE ?", $value . '%');
                         break;
                     case 'subject_mode':
                         $this->grid->sql->where("subject_faculty.subject_mode_id LIKE ?", $value . '%');
                         break;
                     case 'semester_id':
                         $this->grid->sql->where("subject_department.semester_id = ?", $value);
                         break;
                 }
             }
         }
         self::fillgridfinal();
     } else {
         echo '<b>Oops!! </b><br/>No use of peeping like that... :)';
     }
 }
Example #18
0
 public function checkDuplicateQuestionName($categoryId, $question)
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $qry = "select count(*) as count from main_pa_questions aq where aq.pa_category_id =" . $categoryId . " AND aq.question='" . $question . "' AND aq.isactive=1 ";
     $res = $db->query($qry)->fetchAll();
     return $res;
 }
Example #19
0
 /**
  * Get trip paginator adapter
  * @param string $filtingField
  * @param string $filtingCriteria
  * @param string $sortingField
  * @return Zend_Paginator_Adapter_DbSelect|Zend_Paginator_Adapter_DbTableSelect
  */
 public function getTripPaginatorAdapter($filtingField, $filtingCriteria, $sortingField)
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $select = $db->select()->from(array('t' => 'trip'), array('t.trip_id', 't.departure_time', 't.arrival_time', 'fare'))->joinInner(array('r' => 'route'), 't.route_id = r.route_id', array('r.from_city', 'r.to_city'));
     if (!empty($filtingField)) {
         // switch filting field
         switch ($filtingField) {
             case 'departure_time':
             case 'arrival_time':
                 if (!empty($filtingCriteria)) {
                     $dateFormat = new Zend_Date($filtingCriteria, 'dd-MM-y HH:mm:ss');
                     $filtingCriteria = $dateFormat->toString('y-MM-dd HH:mm:ss');
                 }
                 break;
             case 'from_city':
             case 'to_city':
                 $db = Zend_Db_Table::getDefaultAdapter();
                 $select = $db->select()->from(array('t' => 'trip'), array('t.trip_id', 't.departure_time', 't.arrival_time', 'fare'))->joinInner(array('r' => 'route'), 't.route_id = r.route_id', array('r.from_city', 'r.to_city'));
                 break;
             default:
                 break;
         }
         // add filting criteria
         $select->where($filtingField . ' = ?', $filtingCriteria);
     }
     // add sorting criteria
     if (!empty($sortingField)) {
         $select->order($sortingField);
     }
     $adapter = new Zend_Paginator_Adapter_DbSelect($select);
     return $adapter;
 }
Example #20
0
 public function getQuatre($last)
 {
     //retourne la suite des photos en appel ajax
     $db = Zend_Db_Table::getDefaultAdapter();
     $requete = 'SELECT * FROM photo WHERE idPhoto < ' . $last . ' ORDER BY idPhoto DESC LIMIT 0,4';
     return $db->query($requete)->fetchAll();
 }
Example #21
0
 public function insertGroup($param)
 {
     $dbAdapter = Zend_Db_Table::getDefaultAdapter();
     $dbAdapter->insert('AGroup', array('name' => $param));
     $insertid = $dbAdapter->lastInsertId();
     return $insertid;
 }
Example #22
0
 public function indexAction()
 {
     $form = new Application_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost()) {
         //      if ($form->isValid($this->_getAllParams()))
         if ($form->isValid($request->getPost())) {
             $dbAdapter = Zend_Db_Table::getDefaultAdapter();
             $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
             $authAdapter->setTableName('smo_usuario')->setIdentityColumn('usu_rut')->setCredentialColumn('usu_passwd')->setCredentialTreatment('md5(CONCAT(?,usu_passwd_salt))');
             $authAdapter->setIdentity($form->getValue('rut'))->setCredential($form->getValue('pass'));
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 // get all info about this user from the login table  // ommit only the password, we don't need that
                 $userInfo = $authAdapter->getResultRowObject(null, 'password');
                 // the default storage is a session with namespace Zend_Auth
                 $authStorage = $auth->getStorage();
                 $authStorage->write($userInfo);
                 return $this->_helper->redirector->gotoSimple('index', 'index');
                 //$this->_redirect('view/index/index');
             } else {
                 $errorMessage = "Datos Incorrectos, intente de nuevo.";
             }
         }
     }
     $this->view->form = $form;
     $this->view->errorMessage = $errorMessage;
 }
Example #23
0
 protected function _getAuthAdapter()
 {
     $dbAdapter = Zend_Db_Table::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     $authAdapter->setTableName('users')->setIdentityColumn('username')->setCredentialColumn('password')->setCredentialTreatment('SHA1(CONCAT(?,salt))');
     return $authAdapter;
 }
Example #24
0
 public static function login($login, $senha)
 {
     $dbAdapter = Zend_Db_Table::getDefaultAdapter();
     //Inicia o adaptador Zend_Auth para banco de dados
     $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     $authAdapter->setTableName('users')->setIdentityColumn('login')->setCredentialColumn('password')->setCredentialTreatment('SHA1(?)');
     //Define os dados para processar o login
     $authAdapter->setIdentity($login)->setCredential($senha);
     //Faz inner join dos dados do perfil no SELECT do Auth_Adapter
     $select = $authAdapter->getDbSelect();
     $select->join('roles', 'roles.id_role = users.id_role', array('role_roles' => 'role', 'id_role'));
     //Efetua o login
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     //Verifica se o login foi efetuado com sucesso
     if ($result->isValid()) {
         //Recupera o objeto do usuário, sem a senha
         $info = $authAdapter->getResultRowObject(null, 'password');
         $usuario = new Application_Model_Users();
         $usuario->setFullName($info->nome);
         $usuario->setUserName($info->login);
         $usuario->setRoleId($info->role_roles);
         $usuario->setRoleCod($info->id_role);
         $storage = $auth->getStorage();
         $storage->write($usuario);
         return true;
     }
     throw new Exception('Nome de usuário ou senha inválida');
 }
 public function checkduplicaterequestname($servicedeskid, $requestname)
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $qry = "select count(*) as count from main_sd_reqtypes sd where sd.service_request_name ='" . $requestname . "' AND sd.service_desk_id='" . $servicedeskid . "' AND sd.isactive=1 ";
     $res = $db->query($qry)->fetchAll();
     return $res;
 }
Example #26
0
 public function __construct($invoice)
 {
     // ToDo: Pass configuration options
     $this->_db = Zend_Db_Table::getDefaultAdapter();
     $this->_id = $invoice;
     $this->_initData();
 }
Example #27
0
 public function getempmedicalclaimtypes($userId)
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $Data = $db->query('select if(injury_type = 1, "paternity",if(injury_type = 2 , "maternity",if (injury_type = 3,"disability","injury"))) as injuryType from main_empmedicalclaims where isactive =1 and user_id =' . $userId);
     $data = $Data->fetchAll();
     return $data;
 }
 protected function initLog()
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $columns = $this->parseColumns();
     $writer = new Zend_Log_Writer_Db($db, 'historico', $columns);
     $this->setLogger(new Zend_Log($writer));
 }
 public function collectionsafterinsert()
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $pageId = !empty($_GET['pages_id']) ? $_GET['pages_id'] : 0;
     if ($_POST) {
         $id = 0;
         $files = $_FILES['preview'];
         //            var_dump($files);exit;
         if (!empty($files)) {
             //                $lastId = $db->lastInsertId('collections');
             //                if(strpos($_SERVER['REQUEST_URI'], 'edit') !== FALSE){
             //                    $id = $pageId;
             //                }
             //                if(strpos($_SERVER['REQUEST_URI'], 'add') !== FALSE){
             //                    $id = $lastId;
             //                }
             if (!is_dir($_SERVER['DOCUMENT_ROOT'] . '/public/uploadimg')) {
                 mkdir($_SERVER['DOCUMENT_ROOT'] . '/public/uploadimg');
             }
             //                var_dump($img);exit;
             if ($_FILES['preview']['name'] != '') {
                 $db->update('collections', array('img' => $files['name']), 'id=' . $pageId);
                 move_uploaded_file($files['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/public/uploadimg/' . $files['name']);
             }
         }
     }
     if ($pageId != 0) {
         $sql = $db->select()->from(array('fc' => 'film_collection'))->join(array('f' => 'films'), 'f.id = fc.film_id', array('f.name'))->where('fc.collection_id =?', $pageId);
         $films = $db->query($sql)->fetchAll();
         $this->view->films = $films;
         return $films;
     }
 }
Example #30
0
 /**
  * Helper para pegar as imagens do webservice
  *
  */
 public function GetDadosUsuario()
 {
     $auth = Zend_Auth::getInstance();
     $db = Zend_Db_Table::getDefaultAdapter();
     $chAction = strtolower(Zend_Controller_Front::getInstance()->getRequest()->getActionName());
     $chController = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
     $sql = 'select ';
     $sql .= '	u.*, ';
     $sql .= '	a.nm_avatar, ';
     $sql .= '	a.tp_avatar, ';
     $sql .= '	a.sz_avatar, ';
     $sql .= '	a.arquivo ';
     $sql .= 'from ';
     $sql .= '	sca_usuario u ';
     $sql .= '	left join sgg_avatar a on a.id_avatar = u.id_avatar ';
     $sql .= 'where u.st_usuario = 1 ';
     $sql .= 'and u.id_usuario = ' . $auth->getIdentity()->id_usuario;
     $result = $db->fetchRow($sql);
     if ($result) {
         if ($result['arquivo']) {
             $result['arquivo'] = "data:" . $result['tp_avatar'] . ";base64," . base64_encode($result['arquivo']);
         }
     }
     return $result;
 }