Example #1
0
 function &dm2_create_callback(&$controller)
 {
     $this->_event = new fi_kilonkipinat_events_event_dba();
     $this->_event->topic = $this->_request_data['content_topic']->id;
     if (!$this->_event->create()) {
         debug_push_class(__CLASS__, __FUNCTION__);
         debug_print_r('We operated on this object:', $this->_event);
         debug_pop();
         $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, 'Failed to create a new event, cannot continue. Last Midgard error was: ' . midcom_application::get_error_string());
         // This will exit.
     }
     return $this->_event;
 }
Example #2
0
 function &dm2_create_callback(&$controller)
 {
     $this->_jobgroup = new fi_kilonkipinat_account_jobhistory_jobgroup_dba();
     $this->_jobgroup->_use_activitystream = false;
     $this->_use_activitystream = false;
     if (!$this->_jobgroup->create()) {
         debug_push_class(__CLASS__, __FUNCTION__);
         debug_print_r('We operated on this object:', $this->_jobgroup);
         debug_pop();
         $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, 'Failed to create a new jobgroup, cannot continue. Last Midgard error was: ' . midcom_application::get_error_string());
         // This will exit.
     }
     return $this->_jobgroup;
 }
Example #3
0
 /**
  * Set the content topic to use. This will check against the configuration setting 'symlink_topic'.
  * We don't do sanity checking here for performance reasons, it is done when accessing the topic,
  * that should be enough.
  *
  * @access protected
  */
 function _determine_content_topic()
 {
     $guid = $this->_config->get('symlink_topic');
     if (is_null($guid) || $guid == false) {
         // No symlink topic
         // Workaround, we should talk to a DBA object automatically here in fact.
         $this->_content_topic = new midcom_db_topic($this->_topic->id);
         debug_pop();
         return;
     }
     $this->_content_topic = new midcom_db_topic($guid);
     if (!$this->_content_topic) {
         debug_push_class(__CLASS__, __FUNCTION__);
         debug_add('Failed to open symlink content topic, (might also be an invalid object) last Midgard Error: ' . midcom_application::get_error_string(), MIDCOM_LOG_ERROR);
         debug_pop();
         $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 'Failed to open symlink content topic.');
         // This will exit.
     }
 }
Example #4
0
 /**
  * The handler for the index article.
  *
  * @param mixed $handler_id the array key from the request array
  * @param array $args the arguments given to the handler
  * @param Array &$data The local request data.
  * @return boolean Indicating success.
  */
 function _handler_manageRequest($handler_id, $args, &$data)
 {
     $_MIDCOM->auth->require_admin_user();
     $this->_request_data['name'] = "fi.kilonkipinat.accountregistration";
     $this->_update_breadcrumb_line($handler_id);
     $title = $this->_l10n_midcom->get('fi.kilonkipinat.accountregistration');
     $_MIDCOM->set_pagetitle(":: {$title}");
     $prefix = $this->_request_data['prefix'];
     $request = new fi_kilonkipinat_accountregistration_accountrequest_dba(trim($args[0]));
     if (!isset($request) || !isset($request->guid) || $request->guid == '' || $request->guid != $args[0]) {
         debug_push_class(__CLASS__, __FUNCTION__);
         debug_pop();
         $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, 'Failed to load request, cannot continue. Last Midgard error was: ' . midcom_application::get_error_string());
         // This will exit.
     }
     $this->_request_data['request'] = $request;
     if (isset($_POST) && isset($_POST['username'])) {
         if (isset($_POST['isduplicate']) && $_POST['isduplicate'] == '1') {
             $request->status = FI_KILONKIPINAT_ACCOUNTREGISTRATION_ACCOUNT_STATUS_INVALID;
             $request->update();
             $message['title'] = $this->_l10n_midcom->get("Poistettu");
             $message['content'] = $this->_l10n_midcom->get("Kyseinen hakemus on merkattu duplikaatiksi, ts poistettu.");
         } else {
             if (isset($_POST['merge_user_guid']) && $_POST['merge_user_guid'] != '') {
                 $person = new fi_kilonkipinat_account_person_dba(trim($_POST['merge_user_guid']));
             } else {
                 $qb = fi_kilonkipinat_account_person_dba::new_query_builder();
                 $qb->add_constraint('username', '=', trim($_POST['username']));
                 $results = $qb->execute();
                 if (count($results) > 0) {
                     $message['title'] = $this->_l10n_midcom->get("error");
                     $message['content'] = $this->_l10n_midcom->get("Kyseinen tyyppi on jo olemassa");
                 } else {
                     $person = new fi_kilonkipinat_account_person_dba();
                     $person->username = trim($_POST['username']);
                     $person->create();
                 }
             }
             if (isset($person)) {
                 $person->firstname = $request->firstname;
                 $person->lastname = $request->lastname;
                 $person->email = $request->email;
                 $password = fi_kilonkipinat_accountregistration_viewer::generatePassword($this->_config->get('password_length'));
                 // Enforce crypt mode
                 $salt = chr(rand(64, 126)) . chr(rand(64, 126));
                 $crypt_password = crypt($password, $salt);
                 $person->password = $crypt_password;
                 $person->update();
                 if (isset($_POST['add_to_groups']) && count($_POST['add_to_groups']) > 0) {
                     foreach ($_POST['add_to_groups'] as $group_guid) {
                         $group = new midcom_db_group($group_guid);
                         if (isset($group) && isset($group->guid) && $group->guid == $group_guid) {
                             $membership = new midcom_db_member();
                             $membership->uid = $person->id;
                             $membership->gid = $group->id;
                             $membership->create();
                         }
                     }
                 }
                 $person->set_privilege('midgard:owner', "user:{$person->guid}");
                 $request->status = FI_KILONKIPINAT_ACCOUNTREGISTRATION_ACCOUNT_STATUS_RESOLVED;
                 $request->personGuid = $person->guid;
                 $request->update();
                 $subject = 'Tunnuksesi kilonkipinat.fi-sivustolle';
                 $body = sprintf('Hei %s', $person->firstname);
                 $body .= "\n\n";
                 $body .= sprintf('käyttäjätunnus: %s', $person->username);
                 $body .= "\n\n";
                 $body .= sprintf('salasana: %s', $password);
                 $mail = new org_openpsa_mail();
                 $mail->from = $this->_config->get('mail_sender_title') . ' <' . $this->_config->get('mail_sender_address') . '>';
                 $mail->to = $person->firstname . ' ' . $person->lastname . ' <' . $person->email . '>';
                 $mail->body = $body;
                 $mail->subject = $subject;
                 $message = array();
                 if ($mail->send('mail')) {
                     $message['title'] = $this->_l10n_midcom->get("Onnistui");
                     $message['content'] = '';
                 } else {
                     $message['title'] = $this->_l10n_midcom->get("error");
                     $message['content'] = $this->_l10n_midcom->get("Oops, something went wrong.");
                 }
             }
         }
         $this->_request_data['message'] = $message;
     }
     return true;
 }
Example #5
0
 public static function init()
 {
     ///////////////////////////////////
     // Try to be smart about the paths:
     // Define default constants
     if (!defined('MIDCOM_ROOT')) {
         define('MIDCOM_ROOT', dirname(__FILE__));
     }
     require MIDCOM_ROOT . '/compat/environment.php';
     midcom_compat_environment::initialize();
     if (!defined('MIDCOM_STATIC_ROOT')) {
         $pos = strrpos(MIDCOM_ROOT, '/');
         if ($pos === false) {
             // No slash, this is strange
             _midcom_stop_request('MIDCOM_ROOT did not contain a slash, this should not happen and is most probably the cause of a configuration error.');
         }
         define('MIDCOM_STATIC_ROOT', substr(MIDCOM_ROOT, 0, $pos) . '/static');
     }
     if (!defined('MIDCOM_STATIC_URL')) {
         define('MIDCOM_STATIC_URL', '/midcom-static');
     }
     if (!defined('MIDCOM_CONFIG_FILE_BEFORE')) {
         define('MIDCOM_CONFIG_FILE_BEFORE', '/etc/midgard/midcom.conf');
     }
     if (!defined('MIDCOM_CONFIG_FILE_AFTER')) {
         define('MIDCOM_CONFIG_FILE_AFTER', '/etc/midgard/midcom-after.conf');
     }
     ///////////////////////////////////////
     //Constants, Globals and Configuration
     require MIDCOM_ROOT . '/constants.php';
     require MIDCOM_ROOT . '/midcom/connection.php';
     require MIDCOM_ROOT . '/midcom/config/midcom_config.php';
     ini_set('track_errors', '1');
     require MIDCOM_ROOT . '/errors.php';
     // Register autoloader so we get all MidCOM classes loaded automatically
     spl_autoload_register(array('midcom', 'autoload'));
     if (file_exists(MIDCOM_ROOT . '/../vendor/autoload.php')) {
         $loader = (require MIDCOM_ROOT . '/../vendor/autoload.php');
         $loader->register();
     }
     /////////////////////
     // Start the Debugger
     require MIDCOM_ROOT . '/midcom/debug.php';
     debug_add("Start of MidCOM run: {$_SERVER['REQUEST_URI']}");
     self::$_services['auth'] = new midcom_services_auth();
     self::$_services['auth']->initialize();
     /* Load and start up the cache system, this might already end the request
      * on a content cache hit. Note that the cache check hit depends on the i18n and auth code.
      */
     self::$_services['cache'] = new midcom_services_cache();
     /////////////////////////////////////
     // Instantiate the MidCOM main class
     self::$_application = new midcom_application();
     if (!empty($GLOBALS['midcom_config']['midcom_use_superglobal'])) {
         require_once MIDCOM_ROOT . '/compat/superglobal.php';
         $_MIDCOM = new midcom_compat_superglobal();
     }
     self::$_application->initialize();
     if (file_exists(MIDCOM_CONFIG_FILE_AFTER)) {
         include MIDCOM_CONFIG_FILE_AFTER;
     }
 }
Example #6
0
 /**
  * Object create callback
  *
  * @param mixed $handler_id The ID of the handler.
  */
 function &dm2_create_callback(&$controller)
 {
     $this->_object = new fi_opengov_datacatalog_dataset_suggestion_dba();
     if ($_MIDCOM->auth->request_sudo('fi.opengov.datacatalog')) {
         if (!$this->_object->create()) {
             debug_push_class(__CLASS__, __FUNCTION__);
             debug_print_r('We operated on this object:', $this->_object);
             debug_pop();
             $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, 'Failed to create a new dataset suggestion, cannot continue. Last Midgard error was: ' . midcom_application::get_error_string());
             // This will exit.
         }
     }
     $_MIDCOM->auth->drop_sudo();
     /**
      * in order to display this UI message to anonymous users
      * allow midcom:ajax in code_init_after_midcom
      */
     $_MIDCOM->uimessages->add($_MIDCOM->i18n->get_string('thank_you', 'fi.opengov.datacatalog'), $_MIDCOM->i18n->get_string('suggestion_recorded_feedback', 'fi.opengov.datacatalog'));
     return $this->_object;
 }
Example #7
0
 /**
  * Object create callback
  *
  * @param mixed $handler_id The ID of the handler.
  */
 function &dm2_create_callback(&$controller)
 {
     $this->_object = new fi_opengov_datacatalog_dataset_dba();
     $this->_object->organization = array_pop($_POST['fi_opengov_datacatalog_organization_chooser_widget_selections']);
     $this->_object->license = array_pop($_POST['fi_opengov_datacatalog_license_chooser_widget_selections']);
     if (!$this->_object->create()) {
         debug_push_class(__CLASS__, __FUNCTION__);
         debug_print_r('We operated on this object:', $this->_object);
         debug_pop();
         $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, 'Failed to create a new dataset, cannot continue. Last Midgard error was: ' . midcom_application::get_error_string());
         // This will exit.
     }
     /* if the dataset is created based on a suggestion then delete the suggestion */
     if (isset($this->_defaults['suggestion'])) {
         $suggestion = new fi_opengov_datacatalog_dataset_suggestion_dba($this->_defaults['suggestion']);
         $suggestion->delete();
     }
     return $this->_object;
 }
Example #8
0
 function &dm2_create_callback(&$controller)
 {
     $this->_todo = new fi_kilonkipinat_todos_todoitem_dba();
     $this->_todo->topic = $this->_request_data['content_topic']->id;
     $this->_todo->status = FI_KILONKIPINAT_TODOS_TODOITEM_STATUS_NEW;
     if (!$this->_todo->create()) {
         debug_push_class(__CLASS__, __FUNCTION__);
         debug_print_r('We operated on this object:', $this->_todo);
         debug_pop();
         $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, 'Failed to create a new todo, cannot continue. Last Midgard error was: ' . midcom_application::get_error_string());
         // This will exit.
     }
     return $this->_todo;
 }
Example #9
0
 /**
  * Object create callback
  *
  * @param mixed $handler_id The ID of the handler.
  */
 function &dm2_create_callback(&$controller)
 {
     $this->_object = new fi_opengov_datacatalog_info_dba();
     $this->_object->type = $this->_request_data['type'];
     if (!$this->_object->create()) {
         debug_push_class(__CLASS__, __FUNCTION__);
         debug_print_r('We operated on this object:', $this->_object);
         debug_pop();
         $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, 'Failed to create a new info [' . $this->_request_data['type'] . '], cannot continue. Last Midgard error was: ' . midcom_application::get_error_string());
         // This will exit.
     }
     return $this->_object;
 }