Esempio n. 1
0
 /**
  * 
  * Controller constructor creates an instance of Staple_View and saves it in the $view
  * property. It then calls the overridable method _start() for additional boot time
  * procedures.
  */
 public function __construct()
 {
     //Set default access levels
     $methods = get_class_methods(get_class($this));
     foreach ($methods as $acMeth) {
         if (substr($acMeth, 0, 1) != '_') {
             $this->accessLevels[$acMeth] = 1;
         }
     }
     //Create a view object
     $this->view = new Staple_View();
     //Assign the default layout to the controller, if specified in config.
     $settings = Staple_Config::get('layout');
     if (array_key_exists('default', $settings)) {
         if ($settings['default'] != '') {
             $this->_setLayout($settings['default']);
             $pageSettings = Staple_Config::get('page');
             if (array_key_exists('title', $pageSettings)) {
                 $this->layout->setTitle($pageSettings['title']);
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * 
  * Default constructor. Accepts optional values for To, From, CC, and BCC.
  * @param string | array $to
  * @param string $from
  * @param array $cc
  * @param array $bcc
  */
 public function __construct($to = NULL, $from = NULL, array $cc = array(), array $bcc = array())
 {
     //Load the ini settings
     $settings = Staple_Config::get('email');
     if ($settings['from'] != '') {
         $this->setFrom($settings['from']);
     }
     if ($settings['bcc'] != '') {
         $this->addBcc($settings['bcc']);
     }
     if ($settings['html'] == '0') {
         $this->sendAsHtml(false);
     }
     if ($settings['server'] != '') {
         $this->setServer($settings['server']);
     }
     if (array_key_exists('template', $settings)) {
         if ($settings['template'] != '') {
             $this->setTemplate($settings['template']);
         }
     }
     //Load any Tos
     if (isset($to)) {
         if (is_array($to)) {
             foreach ($to as $email) {
                 $this->addTo($email);
             }
         } else {
             $this->addTo($to);
         }
     }
     //Load the From
     if (isset($from)) {
         $this->setFrom($from);
     }
     //Load any CCs
     if (isset($cc)) {
         if (is_array($cc)) {
             $this->setCc($cc);
         } else {
             $this->setCc(array($cc));
         }
     }
     //Load any BCCs
     if (isset($bcc)) {
         if (is_array($bcc)) {
             $this->setBcc($bcc);
         } else {
             $this->setBcc(array($bcc));
         }
     }
 }
Esempio n. 3
0
 /**
  * Creates and/or returns a named database connection.
  * @return Staple_DB
  * @static
  */
 public static function getNamedConnection($name)
 {
     if (!isset(self::$namedConnections[$name])) {
         $c = __CLASS__;
         self::$namedConnections[$name] = new $c(Staple_Config::get($name));
     }
     return self::$namedConnections[$name];
 }
Esempio n. 4
0
 /**
  * 
  * Loads the AD configuration information and esablishes connection to Active Directory Server
  * 
  * @throws Exception
  */
 protected function __construct()
 {
     $settings = Staple_Config::get('ActiveDirectory');
     $this->host = $settings['host'];
     $this->username = $settings['username'];
     $this->password = $settings['password'];
     $this->domain = $settings['domain'];
     $this->baseDN = $settings['baseDN'];
     $this->LDAPSenabled = $settings['LDAPSenabled'];
     if ($this->LDAPSenabled == 1) {
         $LDAPServer = "ldaps://" . $this->host;
         $this->LDAPConn = ldap_connect($LDAPServer, 636);
     } else {
         $LDAPServer = "ldap://" . $this->host;
         $this->LDAPConn = ldap_connect($LDAPServer, 389);
     }
     ldap_set_option($this->LDAPConn, LDAP_OPT_PROTOCOL_VERSION, 3);
     ldap_set_option($this->LDAPConn, LDAP_OPT_REFERRALS, 0);
     $this->mgmtbind();
 }
Esempio n. 5
0
 public function __construct($name = NULL, $doctype = "html5")
 {
     if (isset($name)) {
         $this->setName($name);
     }
     switch ($doctype) {
         case 'html4_trans':
         case 'html4':
             $this->doctype = self::DOC_HTML4_TRANS;
             break;
         case 'html4_strict':
             $this->doctype = self::DOC_HTML4_STRICT;
             break;
         case 'xhtml_trans':
         case 'xhtml':
             $this->doctype = self::DOC_XHTML_TRANS;
             break;
         case 'xhtml_strict':
             $this->doctype = self::DOC_XHTML_STRICT;
             break;
         default:
             $this->doctype = self::DOC_HTML5;
     }
     $settings = Staple_Config::get('layout');
     if (is_array($settings)) {
         //Add the default title to the layout
         if (array_key_exists('title', $settings)) {
             $this->setTitle($settings['title']);
         }
         //Add the default scripts to the layout
         if (array_key_exists('scripts', $settings)) {
             if (is_array($settings['scripts'])) {
                 foreach ($settings['scripts'] as $src) {
                     $this->addScript($src);
                 }
             } else {
                 $this->addScript($settings['scripts']);
             }
         }
         //Add the default styles to the layout
         if (array_key_exists('styles', $settings)) {
             if (is_array($settings['styles'])) {
                 foreach ($settings['styles'] as $href) {
                     $this->addStylesheet($href);
                 }
             } else {
                 $this->layout->addStylesheet($settings['styles']);
             }
         }
         //Add the default metas to the layout
         if (array_key_exists('meta_description', $settings)) {
             $this->setMetas('description', $settings['meta_description']);
         }
         if (array_key_exists('meta_keywords', $settings)) {
             $this->setMetas('keywords', $settings['meta_keywords']);
         }
     }
 }