Example #1
0
 /**
  * Checks the database for the existance of the table inside the database, and whether modifications can be made on
  * the table based on the $state variable. if called without the $state variable, this method will check whether the
  * whole resource is disabled.
  * @param  string $package The package name
  * @param  string $state   The state of the action: list, insert, update, remove
  * @return boolean         Whether the system can go ahead with next logic
  */
 public function packageOK($package, $state = null)
 {
     $stateStr = $state ? 'and `' . $state . '` = "true"' : '';
     $packages = R::find('managepackages', ' name = ? and enabled = "true" ' . $stateStr, array($this->cleanup($package)));
     if (count($packages) > 0) {
         foreach ($packages as $package) {
             if ($package->locked === 'true') {
                 R::freeze(true);
             }
         }
         return true;
     }
     return false;
 }
Example #2
0
 public static function setupRedBeans()
 {
     $config = Config::get();
     if (!isset($config['db']['host'])) {
         throw new Exception('Config[db][host] not set. Check api.conf in project folder.');
     }
     if (!isset($config['db']['db'])) {
         throw new Exception('Config[db][db] not set. Check api.conf in project folder.');
     }
     if (!isset($config['db']['user'])) {
         throw new Exception('Config[db][user] not set. Check api.conf in project folder.');
     }
     if (!isset($config['db']['password'])) {
         throw new Exception('Config[db][password] not set. Check api.conf in project folder.');
     }
     R::setup('mysql:host=' . $config['db']['host'] . ';dbname=' . $config['db']['db'], $config['db']['user'], $config['db']['password'], true);
     R::exec('SET NAMES utf8mb4');
     R::freeze(true);
 }