Esempio n. 1
0
 /**
  * Get and unserialize serialized settings
  *
  * @param string $theme theme folder name
  * @param string $return 'value' or 'default'
  * @return array - of theme settings
  */
 public function getThemeSettings($h, $theme = '', $return = 'value')
 {
     if (!$theme) {
         $theme = rtrim(THEME, '/');
     }
     //$settings = \Hotaru\Models\Miscdata::getAllThemeSettings($theme);
     $settings = \Hotaru\Models2\Miscdata::getAllThemeSettings($h, $theme);
     //		// Get settings from the database if they exist...
     //		$sql = "SELECT miscdata_value, miscdata_default FROM " . TABLE_MISCDATA . " WHERE miscdata_key = %s";
     //		$query = $h->db->prepare($sql, $theme . '_settings');
     //
     //                $h->smartCache('on', 'miscdata', 60, $query); // start using cache
     //                $settings = $h->db->get_row($query);
     //                $h->smartCache('off'); // stop using cache
     if (!$settings) {
         return false;
     }
     if ($return == 'value') {
         $settings = unserialize($settings->miscdata_value);
     } else {
         $settings = unserialize($settings->miscdata_default);
     }
     return $settings;
 }
Esempio n. 2
0
 /**
  * Add Custom User Role
  *
  * @param string $new_role name of new custom role
  * @return bool
  */
 public function addCustomRole($h, $new_role = '', $base_role = 'default')
 {
     if (!$new_role) {
         return false;
     }
     $new_role = mb_strtolower($new_role, 'UTF-8');
     // test if this role name is reserved:
     $default_roles = $this->getDefaultRoles();
     if (in_array($new_role, $default_roles)) {
         return false;
     }
     // test if this role name is already a custom role:
     $custom_roles = $this->getCustomRoles($h);
     if ($custom_roles && in_array($new_role, $custom_roles)) {
         return false;
     }
     // add new role to custom roles
     if (!$custom_roles) {
         $custom_roles = array();
     }
     array_push($custom_roles, $new_role);
     // check custom_roles row exists in the database:
     //$result = \HotaruModels\Miscdata::getCurrentValue('custom_roles');
     $result = \Hotaru\Models2\Miscdata::getCurrentValue($h, 'custom_roles');
     // update or insert accordingly
     if ($result) {
         \Hotaru\Models2\Miscdata::update($h, serialize($custom_roles), 'custom_roles');
         //$sql = "UPDATE " . TABLE_MISCDATA . " SET miscdata_value = %s, miscdata_updateby = %d WHERE miscdata_key = %s";
         //$h->db->query($h->db->prepare($sql, serialize($custom_roles), $h->currentUser->id, 'custom_roles'));
     } else {
         \Hotaru\Models2\Miscdata::add($h, serialize($custom_roles), 'custom_roles');
         //$sql = "INSERT INTO " . TABLE_MISCDATA . " (miscdata_key, miscdata_value, miscdata_updateby) VALUES(%s, %s, %d)";
         //$h->db->query($h->db->prepare($sql, 'custom_roles', serialize($custom_roles), $h->currentUser->id));
     }
     // Next, update Hotaru's base permissions
     $base_perms = $h->getDefaultPermissions('all', 'base');
     $base_perms = $this->copyRolePerms($h, $base_perms, $new_role, $base_role);
     $h->updateDefaultPermissions($base_perms, 'base');
     // Next, update Hotaru's site permissions
     $site_perms = $h->getDefaultPermissions('all', 'site');
     $site_perms = $this->copyRolePerms($h, $site_perms, $new_role, $base_role);
     $h->updateDefaultPermissions($site_perms, 'site');
     return true;
 }
Esempio n. 3
0
 private function loadSystemJobs()
 {
     if (!isset($this->systemJobs)) {
         $systemJobs = \Hotaru\Models2\Miscdata::getCurrentSettings($this, 'system_jobs');
         try {
             $this->systemJobs = unserialize($systemJobs);
         } catch (Exception $e) {
             //
         }
     }
 }
Esempio n. 4
0
 /**
  * Updates the CRON settings.
  *
  */
 private function _set_cron_array($h, $cron)
 {
     $value = serialize($cron);
     // check if we have a setting first
     $exists = \Hotaru\Models2\Miscdata::exists($h, 'system_jobs');
     if (!$exists) {
         $sql = "INSERT INTO " . TABLE_MISCDATA . " (miscdata_key, miscdata_default, miscdata_value, miscdata_updateby) VALUES (%s, %s, %s, %s)";
         $h->db->query($h->db->prepare($sql, 'system_jobs', '', $value, $h->currentUser->id));
     } else {
         // update existing db record
         $sql = "UPDATE " . TABLE_MISCDATA . " SET miscdata_value = %s, miscdata_updateby = %d WHERE miscdata_key = %s";
         $h->db->query($h->db->prepare($sql, $value, $h->currentUser->id, 'system_jobs'));
     }
     $systemJobs = \Hotaru\Models2\Miscdata::getCurrentSettings($h, 'system_jobs');
     try {
         $h->systemJobs = unserialize($systemJobs);
     } catch (Exception $e) {
         //print "<br/><br/>********** ERROR **********<br/><br/>";
     }
     //$h->updateSetting('cron_settings', serialize($cron), 'cron');
     // need to force update of pluginSettings here also for memCache
 }
Esempio n. 5
0
 /**
  * 
  * @param type $h
  * @param type $type
  */
 public function miscdata($h, $key = '', $cache = 'true')
 {
     //$data = \Hotaru\Models\Miscdata::getCurrentValue($key);
     $data = \Hotaru\Models2\Miscdata::getCurrentValue($h, $key, $cache);
     return $data;
 }