function setUpGroups($lang) { if (!file_exists(GROUP_FILE_LOCATION)) { $aGroupDB = new Groups(); $aGroupDB->setFileName(GROUP_FILE_LOCATION); $names = ImageTypes::getMenuNames(); foreach ($names as $name) { $aGroup = new Group(); $aGroup->setType($lang[$name]); $aGroup->setGroupImage($name); $aGroup->rebuildElementLine(); $aGroupDB->addElement($aGroup); } $aGroupDB->save(); } else { // validate we have all the default groups $addedElement = false; $aGroupDB = new Groups(GROUP_FILE_LOCATION); $names = ImageTypes::getMenuNames(); foreach ($names as $name) { if ($aGroupDB->getAGroup($name) == "") { $aGroup = new Group(); $aGroup->setType($lang[$name]); $aGroup->setGroupImage($name); $aGroup->rebuildElementLine(); $aGroupDB->addElement($aGroup); $addedElement = true; } } if ($addedElement) { $aGroupDB->save(); } } }
function setUpModules($lang) { if (!file_exists(MODULE_FILE_LOCATION)) { $aModuleDB = new ModuleTypes(); $aModuleDB->setFileName(MODULE_FILE_LOCATION); $names = ImageTypes::getModuleNames(); foreach ($names as $name) { $aModule = new Module(); $aModule->setType($lang[$name]); $aModule->setModuleType(ImageTypes::getModuleSpec($name)); $aModule->setModuleImage($name); $aModule->rebuildElementLine(); $aModuleDB->addElement($aModule); } $aModuleDB->save(); } else { // validate we have all the default types $addedElement = false; $aModuleDB = new ModuleTypes(MODULE_FILE_LOCATION); $names = ImageTypes::getModuleNames(); foreach ($names as $name) { if ($aModuleDB->getModuleType($name) == "") { $aModule = new Module(); $aModule->setType($lang[$name]); $aModule->setModuleType(ImageTypes::getModuleSpec($name)); $aModule->setModuleImage($name); $aModule->rebuildElementLine(); $aModuleDB->addElement($aModule); $addedElement = true; } } if ($addedElement) { $aModuleDB->save(); } } }
function &getTypedGroups($reload = false) { if (isset($this->typedGroups) && !$reload) { if ($this->typedGroups->hasFileChanged()) { $reload = true; } } if (!isset($this->typedGroups) || $reload) { $_SESSION['load_count'] += 1; $groupsinstance = new Groups(); $names = ImageTypes::getModuleNames(); foreach ($names as $name) { $aGroup = new Group(); $aGroup->setType($this->lang[$name]); $aGroup->setGroupImage($name); $aGroup->rebuildElementLine(); $groupsinstance->addElement($aGroup); } $this->typedGroups =& $groupsinstance; } return $this->typedGroups; }
require_once '..' . DIRECTORY_SEPARATOR . 'include.php'; require_once '..' . DIRECTORY_SEPARATOR . 'include_globals.php'; require_once CLASS_FILE_LOCATION . '/imagetypes.class.php'; ## Security validation's $authCheck = new Login(USERDB_FILE_LOCATION, $config['use_domus_security']); if (!$authCheck->login()) { header("Location: ../login.php?from=admin/users"); exit; } if ($authCheck->getUser()->getSecurityLevel() != 0) { header("Location: ../index.php"); exit; } $tpl->set('sec_level', $authCheck->getUser()->getSecurityLevel()); $groupings = $groups->getElementObjects(ALL_OBJECTS_D); $thenamelist = ImageTypes::getMenuNames(); ## Set template parameters $tpl->set('title', $lang['groups']); $tpl->set('page', 'groups'); $tpl_body = new Template(TPL_FILE_LOCATION . 'groups_view.tpl'); $tpl_body->set('lang', $lang); $tpl_body->set('groups', $groupings); $tpl_body->set('config', $config); $mustSave = false; if (!isset($_GET["action"])) { $tpl_add = new Template(TPL_FILE_LOCATION . 'groups_add.tpl'); $tpl_add->set('lang', $lang); $tpl_add->set('config', $config); $tpl_add->set('imagenames', $thenamelist); $tpl_body->set('form', $tpl_add); } else {
private function editAward($award) { $data = Arr::merge($this->sanitize($_POST), $_FILES); $award->title = $data['name']; $award->desc = $data['description']; if (isset($data['photo']) && $data['photo']['name'] != "") { Upload::$default_directory = Kohana::config('myshot.basePath'); if ($stage_path = Upload::save($data['photo'])) { foreach ($award->_images as $image) { $name = (string) $image->type->name; if ($image->type->name == self::FULL) { $path_info = pathinfo($stage_path); $savedAt = $path_info['dirname'] . '/' . $path_info['filename'] . '.' . $path_info['extension']; Library_Akamai::factory()->addToDir($savedAt, Kohana::config('akamai.honordir')); $image->path = $this->webpath($stage_path); } else { $image->path = $this->webPath($this->resizeHonor($stage_path, ImageTypes::types()->{$name}->size)); } $image->save(); } } } $award->save(); }
private function editBadge($badge) { $data = Arr::merge($this->sanitize($_POST), $_FILES); $badge->title = $data['name']; $badge->desc = $data['description']; if (isset($data['startstop'])) { $badge->available = $data['startyear'] . "-" . $data['startmonth'] . "-" . $data['startday']; $badge->expiration = $data['endyear'] . "-" . $data['endmonth'] . "-" . $data['endday']; } else { $badge->data->available = null; $badge->data->expiration = null; } //Delete unused rules foreach ($badge->rules as $rule) { $stillHere = false; for ($i = 0; $i < count($data['rule_id']); ++$i) { if ($data['rule_id'][$i] == $rule->id) { $stillHere = true; break; } } if (!$stillHere) { $rule->delete(); } } //Add new ones and update existing for ($i = 0; $i < count($data['rule_name']); ++$i) { $event = ORM::factory('game_Event', $data['event'][$i]); if ($data['rule_id'][$i] == 0) { $rule = $badge->createRule($data['rule_name'][$i], $event, $data['event_amount'][$i]); } else { $rule = ORM::factory("game_Rule", $data['rule_id'][$i]); $rule->name = $data['rule_name'][$i]; $rule->event_id = $event->id; $rule->amount = $data['event_amount'][$i]; } if ($data['data_key'][$i] != '' && $data['data_key'][$i] != 'key name') { $rule->log_info_name = $data['data_key'][$i]; $rule->operator = $data['data_method'][$i]; $rule->contains_data = $data['data_content'][$i]; } $rule->save(); } if (isset($data['photo']) && $data['photo']['name'] != "") { Upload::$default_directory = Kohana::config('myshot.basePath'); if ($stage_path = Upload::save($data['photo'])) { foreach ($badge->_images as $image) { $name = (string) $image->type->name; if ($image->type->name == self::FULL) { $path_info = pathinfo($stage_path); $savedAt = $path_info['dirname'] . '/' . $path_info['filename'] . '.' . $path_info['extension']; Library_Akamai::factory()->addToDir($savedAt, Kohana::config('akamai.honordir')); $image->path = $this->webpath($stage_path); } else { $image->path = $this->webPath($this->resizeHonor($stage_path, ImageTypes::types()->{$name}->size)); } $image->save(); } } } $badge->save(); }