<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/

// +----------------------------------------------------------------------+

// | PHP version 4/5                                                      |

// +----------------------------------------------------------------------+

// | Copyright (c) 2004-2010 ARMIA INC                                    |

// +----------------------------------------------------------------------+

// | This source file is a part of iScripts VistaCart                     |

// +----------------------------------------------------------------------+

// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |

// +----------------------------------------------------------------------+

class Admin extends AppModel

{

    var $name = 'Admin';

	

    function validateLogin($data= NULL, $key=NULL)

    {
       if($key=='pass'){
            $admin = $this->find(array('admin_name' => 'admin'), array('id','admin_name','settings','custom','category','products','feedback','users','orders','refund','promocodes','websitecontent','homepage','reports','help','adminusers','newsletter','newsletterusers','sentnewsletters','giftcards','giftcardusers','blog_pword'));
       } else {
            $admin = $this->find(array('admin_name' => $data['username'], 'admin_pword' => md5($data['password'])), array('id','admin_name','settings','custom','category','products','feedback','users','orders','refund','promocodes','websitecontent','homepage','reports','help','adminusers','newsletter','newsletterusers','sentnewsletters','giftcards','giftcardusers','blog_pword'));        
       }
        
        if(empty($admin) == false)
            
            $admin['Admin']['admin_pword'] = $admin['Admin']['blog_pword'];
            return $admin['Admin'];

        return false;

    }  

	function chngpword($aid,$pword){

		$Db = ConnectionManager::getDataSource($this->useDbConfig);

		$adtbl = $Db->fullTableName('admins');

		$this->query("UPDATE  $adtbl SET admin_pword='".md5($pword)."' WHERE id='".$aid."'");

		return true;

	}

}

?>