Example #1
0
 /**
  * Load all the REQUEST variables into the sticky form cache
  *
  * Call this from an action when you want all your submitted variables
  * available if the submission fails validation and is sent back to the form
  */
 function elgg_make_sticky_form()
 {
     elgg_clear_sticky_form();
     $_SESSION['sticky'] = array();
     foreach ($_REQUEST as $key => $var) {
         // will go through XSS filtering on the get function
         $_SESSION['sticky'][$key] = get_input($key);
     }
 }
Example #2
0
 /**
  * Load all the GET and POST variables into the sticky form cache
  *
  * Call this from an action when you want all your submitted variables
  * available if the submission fails validation and is sent back to the form
  *
  * @param string $form_name Name of the sticky form
  *
  * @return void
  */
 public function makeStickyForm($form_name)
 {
     elgg_clear_sticky_form($form_name);
     $session = _elgg_services()->session;
     $data = $session->get('sticky_forms', array());
     $req = _elgg_services()->request;
     // will go through XSS filtering in elgg_get_sticky_value()
     $vars = array_merge($req->query->all(), $req->request->all());
     $data[$form_name] = $vars;
     $session->set('sticky_forms', $data);
 }
Example #3
0
/**
 * Prepare the compose form variables
 *
 * @return array
 */
function messages_prepare_form_vars($recipient_guid = 0)
{
    // input names => defaults
    $values = array('subject' => '', 'body' => '', 'recipient_guid' => $recipient_guid);
    if (elgg_is_sticky_form('messages')) {
        foreach (array_keys($values) as $field) {
            $values[$field] = elgg_get_sticky_value('messages', $field);
        }
    }
    elgg_clear_sticky_form('messages');
    return $values;
}
Example #4
0
/**
 * Prepare the compose form variables
 *
 * @return array
 */
function messages_prepare_form_vars($recipient_guid = 0)
{
    $recipient_username = '';
    $recipient = get_entity($recipient_guid);
    if (elgg_instanceof($recipient, 'user')) {
        $recipient_username = $recipient->username;
    }
    // input names => defaults
    $values = array('subject' => '', 'body' => '', 'recipient_username' => $recipient_username);
    if (elgg_is_sticky_form('messages')) {
        foreach (array_keys($values) as $field) {
            $values[$field] = elgg_get_sticky_value('messages', $field);
        }
    }
    elgg_clear_sticky_form('messages');
    return $values;
}
Example #5
0
/**
 * Prepares variables for the group edit form view.
 *
 * @param mixed $group ElggGroup or null. If a group, uses values from the group.
 * @return array
 */
function groups_prepare_form_vars($group = null)
{
    $values = array('name' => '', 'membership' => ACCESS_PUBLIC, 'vis' => ACCESS_PUBLIC, 'guid' => null, 'entity' => null, 'owner_guid' => elgg_get_logged_in_user_guid(), 'content_access_mode' => ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED);
    // handle customizable profile fields
    $fields = elgg_get_config('group');
    if ($fields) {
        foreach ($fields as $name => $type) {
            $values[$name] = '';
        }
    }
    // handle tool options
    $tools = elgg_get_config('group_tool_options');
    if ($tools) {
        foreach ($tools as $group_option) {
            $option_name = $group_option->name . "_enable";
            $values[$option_name] = $group_option->default_on ? 'yes' : 'no';
        }
    }
    // get current group settings
    if ($group) {
        foreach (array_keys($values) as $field) {
            if (isset($group->{$field})) {
                $values[$field] = $group->{$field};
            }
        }
        if ($group->access_id != ACCESS_PUBLIC && $group->access_id != ACCESS_LOGGED_IN) {
            // group only access - this is done to handle access not created when group is created
            $values['vis'] = ACCESS_PRIVATE;
        } else {
            $values['vis'] = $group->access_id;
        }
        // The content_access_mode was introduced in 1.9. This method must be
        // used for backwards compatibility with groups created before 1.9.
        $values['content_access_mode'] = $group->getContentAccessMode();
        $values['entity'] = $group;
    }
    // get any sticky form settings
    if (elgg_is_sticky_form('groups')) {
        $sticky_values = elgg_get_sticky_values('groups');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('groups');
    return $values;
}
Example #6
0
/**
 * Pull together variables for the save form
 *
 * @param ElggEntity $schedule
 * @return array $values
 */
function scheduling_prepare_form_vars(ElggEntity $schedule = null)
{
    $values = array('guid' => 0, 'title' => '', 'description' => '', 'owner_guid' => elgg_get_logged_in_user_guid(), 'container_guid' => 0, 'access_id' => ACCESS_PUBLIC);
    if ($schedule) {
        foreach ($values as $field => $value) {
            if (isset($schedule->{$field})) {
                $values[$field] = $schedule->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('scheduling')) {
        $sticky_values = elgg_get_sticky_values('scheduling');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('scheduling');
    return $values;
}
Example #7
0
/**
 * Prepare the add/edit form variables
 *
 * @param ElggObject $question A question object.
 * @return array
 */
function answers_prepare_form_vars($question = null)
{
    $values = array('title' => get_input('search', ''), 'description' => '', 'access_id' => ACCESS_DEFAULT, 'tags' => '', 'container_guid' => elgg_get_page_owner_guid(), 'guid' => null, 'entity' => $question);
    if ($question) {
        foreach (array_keys($values) as $field) {
            if (isset($question->{$field})) {
                $values[$field] = $question->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('question')) {
        $sticky_values = elgg_get_sticky_values('question');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('question');
    return $values;
}
Example #8
0
/**
 * Prepare the add/edit form variables
 *
 * @param ElggObject $golfscore golfscore object.
 * @return array
 */
function golfscore_prepare_form_vars($golfscore = null)
{
    $values = array('title' => get_input('title', ''), 'address' => get_input('address', ''), 'description' => '', 'access_id' => ACCESS_DEFAULT, 'tags' => '', 'shares' => array(), 'container_guid' => elgg_get_page_owner_guid(), 'guid' => null, 'entity' => $golfscore);
    if ($golfscore) {
        foreach (array_keys($values) as $field) {
            if (isset($golfscore->{$field})) {
                $values[$field] = $golfscore->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('golfscore')) {
        $sticky_values = elgg_get_sticky_values('golfscore');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('golfscore');
    return $values;
}
Example #9
0
/**
 * Prepare the group settings form variables
 *
 * @param ElggObject $group A group object.
 * @return array
 */
function markdown_wiki_group_settings_prepare_form_vars($group = null)
{
    $values = array('markdown_wiki_all_enabled' => get_input('markdown_wiki_all_enabled', false));
    if ($group) {
        foreach (array_keys($values) as $field) {
            if (isset($group->{$field})) {
                $values[$field] = $group->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('markdown_wiki_settings')) {
        $sticky_values = elgg_get_sticky_values('markdown_wiki_settings');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('markdown_wiki_settings');
    return $values;
}
Example #10
0
/**
 * Prepare the add/edit form variables
 *
 * @param ElggObject $video A video object.
 * @return array
 */
function videos_prepare_form_vars($video = null)
{
    // input names => defaults
    $values = array('title' => get_input('title', ''), 'video_url' => get_input('video_url', ''), 'description' => '', 'access_id' => ACCESS_DEFAULT, 'tags' => '', 'container_guid' => elgg_get_page_owner_guid(), 'guid' => null, 'entity' => $video);
    if ($video) {
        foreach (array_keys($values) as $field) {
            if (isset($video->{$field})) {
                $values[$field] = $video->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('videos')) {
        $sticky_values = elgg_get_sticky_values('videos');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('videos');
    return $values;
}
Example #11
0
/**
 * Prepare discussion topic form variables
 *
 * @param ElggObject $topic Topic object if editing
 * @return array
 */
function discussion_prepare_form_vars($topic = NULL)
{
    // input names => defaults
    $values = array('title' => '', 'description' => '', 'status' => '', 'access_id' => ACCESS_DEFAULT, 'tags' => '', 'container_guid' => elgg_get_page_owner_guid(), 'guid' => null, 'topic' => $topic);
    if ($topic) {
        foreach (array_keys($values) as $field) {
            if (isset($topic->{$field})) {
                $values[$field] = $topic->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('topic')) {
        $sticky_values = elgg_get_sticky_values('topic');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('topic');
    return $values;
}
Example #12
0
/**
 * Prepare the add/edit form variables
 *
 * @param ElggObject $page
 * @return array
 */
function pages_prepare_form_vars($page = null, $parent_guid = 0)
{
    // input names => defaults
    $values = array('title' => '', 'description' => '', 'access_id' => ACCESS_DEFAULT, 'write_access_id' => ACCESS_DEFAULT, 'tags' => '', 'container_guid' => elgg_get_page_owner_guid(), 'guid' => null, 'entity' => $page, 'parent_guid' => $parent_guid);
    if ($page) {
        foreach (array_keys($values) as $field) {
            if (isset($page->{$field})) {
                $values[$field] = $page->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('page')) {
        $sticky_values = elgg_get_sticky_values('page');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('page');
    return $values;
}
/**
 * Pull together variables for the edit form
 *
 * @param ElggObject       $event
 * @return array
 */
function sched_conf_prepare_edit_form_vars($conf = NULL)
{
    // input names => defaults
    $values = array('title' => NULL, 'description' => NULL, 'application' => NULL, 'application_code' => NULL, 'immediate' => NULL, 'start_date' => NULL, 'start_time_h' => NULL, 'start_time_m' => NULL, 'tags' => NULL, 'access_id' => ACCESS_DEFAULT, 'group_guid' => NULL, 'guid' => NULL, 'start_time' => NULL);
    if ($conf) {
        foreach (array_keys($values) as $field) {
            if (isset($conf->{$field})) {
                $values[$field] = $conf->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('sched_conf')) {
        $sticky_values = elgg_get_sticky_values('sched_conf');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('sched_conf');
    return $values;
}
Example #14
0
/**
 * Add amapnews form parameters
 * 
 * @param type $entity_unit
 * @return type
 */
function amapnews_prepare_form_vars($entity_unit = null)
{
    // input names => defaults
    $values = array('title' => '', 'description' => '', 'excerpt' => '', 'featured' => '', 'photo' => '', 'tags' => '', 'connected_guid' => null, 'access_id' => ACCESS_DEFAULT, 'container_guid' => elgg_get_page_owner_guid(), 'entity' => $entity_unit, 'guid' => null, 'comments_on' => NULL);
    if ($entity_unit) {
        foreach (array_keys($values) as $field) {
            if (isset($entity_unit->{$field})) {
                $values[$field] = $entity_unit->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('amapnews')) {
        $sticky_values = elgg_get_sticky_values('amapnews');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('amapnews');
    return $values;
}
Example #15
0
/**
 * Prepare the add/edit form variables
 *
 * @param ElggObject $task
 * @return array
 */
function tasks_prepare_form_vars($task = null, $parent_guid = 0)
{
    // input names => defaults
    $values = array('title' => '', 'description' => '', 'start_date' => '', 'end_date' => '', 'task_type' => '', 'status' => '', 'assigned_to' => '', 'percent_done' => '', 'work_remaining' => '', 'access_id' => ACCESS_DEFAULT, 'write_access_id' => ACCESS_DEFAULT, 'tags' => '', 'container_guid' => elgg_get_page_owner_guid(), 'guid' => null, 'entity' => $task, 'parent_guid' => $parent_guid);
    if ($task) {
        foreach (array_keys($values) as $field) {
            if (isset($task->{$field})) {
                $values[$field] = $task->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('task')) {
        $sticky_values = elgg_get_sticky_values('task');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('task');
    return $values;
}
Example #16
0
/**
 * Prepare the map creation form variables
 * 
 * @param type $drawmap
 * @return type
 */
function sharemaps_prepare_form_vars_drawmap($drawmap = null)
{
    // input names => defaults
    $values = array('title' => '', 'description' => '', 'access_id' => ACCESS_DEFAULT, 'tags' => '', 'container_guid' => elgg_get_page_owner_guid(), 'guid' => null, 'dm_markers' => '', 'entity' => $drawmap);
    if ($drawmap) {
        foreach (array_keys($values) as $field) {
            if (isset($drawmap->{$field})) {
                $values[$field] = $drawmap->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('drawmap')) {
        $sticky_values = elgg_get_sticky_values('drawmap');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('drawmap');
    return $values;
}
Example #17
0
function vouchers_prepare_form_vars($voucher = null)
{
    // input names => defaults
    $values = array('title' => '', 'code' => '', 'code_type' => '', 'code_end' => '', 'description' => '', 'amount' => '', 'amount_type' => '', 'access_id' => ACCESS_DEFAULT, 'tags' => '', 'container_guid' => elgg_get_page_owner_guid(), 'entity' => $voucher, 'valid_from' => '', 'valid_until' => '', 'price' => 0, 'points' => 0, 'howmany' => '', 'currency' => '', 'weburl' => '', 'vimage' => '', 'qrcode' => '', 'zone' => '', 'terms' => '', 'excerpt' => '', 'guid' => null, 'comments_on' => NULL);
    if ($voucher) {
        foreach (array_keys($values) as $field) {
            if (isset($voucher->{$field})) {
                $values[$field] = $voucher->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('vouchers')) {
        $sticky_values = elgg_get_sticky_values('vouchers');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('vouchers');
    return $values;
}
Example #18
0
 /**
  * Executes an action
  * Triggers 'action:after', $ation hook that allows you to filter the Result object
  *
  * @param Action $controller Action name or instance of Action
  * @param bool  $feedback    Display errors and messages
  * @return ActionResult
  */
 public function execute(Action $controller, $feedback = true)
 {
     try {
         $action = $this->parseActionName();
         elgg_make_sticky_form($action);
         $controller->setup();
         if ($controller->validate() === false) {
             throw new ActionValidationException("Invalid input for action {$action}");
         }
         $controller->execute();
         $this->result = $controller->getResult();
     } catch (ActionValidationException $ex) {
         $this->result->addError($ex->getMessage());
         elgg_log($ex->getMessage(), 'ERROR');
     } catch (PermissionsException $ex) {
         $this->result->addError(elgg_echo('apps:permissions:error'));
         elgg_log($ex->getMessage(), 'ERROR');
     } catch (InvalidEntityException $ex) {
         $this->result->addError(elgg_echo('apps:entity:error'));
         elgg_log($ex->getMessage(), 'ERROR');
     } catch (Exception $ex) {
         $this->result->addError(elgg_echo('apps:action:error'));
         elgg_log($ex->getMessage(), 'ERROR');
     }
     $errors = $this->result->getErrors();
     $messages = $this->result->getMessages();
     if (empty($errors)) {
         elgg_clear_sticky_form($action);
     } else {
         $this->result->setForwardURL(REFERRER);
     }
     if ($feedback) {
         foreach ($errors as $error) {
             register_error($error);
         }
         foreach ($messages as $message) {
             system_message($message);
         }
     }
     return elgg_trigger_plugin_hook('action:after', $action, null, $this->result);
 }
Example #19
0
/**
 * Prepare the add/edit form variables
 *
 * @param ElggObject $project
 * @return array
 */
function projects_prepare_form_vars($project = null, $parent_guid = 0)
{
    // input names => defaults
    $values = array('title' => '', 'description' => '', 'project_type' => '', 'cost' => '', 'organization' => '', 'funding' => '', 'status' => '', 'start_date' => '', 'end_date' => '', 'assigned_to[]' => '', 'access_id' => ACCESS_DEFAULT, 'write_access_id' => ACCESS_DEFAULT, 'tags' => '', 'upload' => '', 'container_guid' => elgg_get_page_owner_guid(), 'guid' => null, 'entity' => $project, 'parent_guid' => $parent_guid);
    if ($project) {
        foreach (array_keys($values) as $field) {
            if (isset($project->{$field})) {
                $values[$field] = $project->{$field};
            }
        }
        $opis = elgg_get_entities_from_relationship(array("relationship" => "opi", "relationship_guid" => $project->guid, "inverse_relationship" => true));
        $values['opis'] = $opis;
    }
    if (elgg_is_sticky_form('project')) {
        $sticky_values = elgg_get_sticky_values('project');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('project');
    return $values;
}
Example #20
0
/**
 * Pull together market variables for the save/edit form
 *
 * @param Market $post
 * @return array
 */
function market_prepare_form_vars($post = NULL)
{
    $values = array('title' => NULL, 'description' => NULL, 'price' => NULL, 'access_id' => ACCESS_DEFAULT, 'marketcategory' => NULL, 'market_type' => NULL, 'location' => NULL, 'custom' => NULL, 'tags' => NULL, 'container_guid' => elgg_get_page_owner_guid(), 'guid' => NULL);
    if ($post) {
        foreach (array_keys($values) as $field) {
            if (isset($post->{$field})) {
                $values[$field] = $post->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('market')) {
        $sticky_values = elgg_get_sticky_values('market');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('market');
    if (!$post) {
        return $values;
    }
    return $values;
}
Example #21
0
/**
 * Prepare the add/edit form variables
 *
 * @param ElggObject     $page
 * @param int            $parent_guid
 * @param ElggAnnotation $revision
 * @return array
 */
function pages_prepare_form_vars($page = null, $parent_guid = 0, $revision = null)
{
    // input names => defaults
    $values = array('title' => '', 'description' => '', 'access_id' => ACCESS_DEFAULT, 'write_access_id' => ACCESS_DEFAULT, 'tags' => '', 'container_guid' => elgg_get_page_owner_guid(), 'guid' => null, 'entity' => $page, 'parent_guid' => $parent_guid);
    if ($page) {
        foreach (array_keys($values) as $field) {
            if (isset($page->{$field})) {
                $values[$field] = $page->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('page')) {
        $sticky_values = elgg_get_sticky_values('page');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('page');
    // load the revision annotation if requested
    if ($revision instanceof ElggAnnotation && $revision->entity_guid == $page->getGUID()) {
        $values['description'] = $revision->value;
    }
    return $values;
}
Example #22
0
/**
 * Prepare the add/edit form variables
 *
 * @param ElggObject $task
 * @return array
 */
function task_prepare_form_vars($task = null, $list_guid = 0)
{
    // input names => defaults
    $values = array('title' => get_input('title', ''), 'description' => '', 'priority' => '', 'access_id' => ACCESS_DEFAULT, 'write_access_id' => ACCESS_DEFAULT, 'tags' => '', 'container_guid' => elgg_get_page_owner_guid(), 'guid' => null, 'entity' => $task, 'list_guid' => $list_guid, 'referer_guid' => get_input('referer_guid', ''));
    if ($task) {
        foreach (array_keys($values) as $field) {
            if (isset($task->{$field})) {
                $values[$field] = $task->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('task')) {
        $sticky_values = elgg_get_sticky_values('task');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('task');
    if ($referer = get_input('referer')) {
        $link = elgg_view('output/url', array('href' => $referer, 'text' => elgg_echo('tasks:this:moreinfo:here')));
        $values['description'] .= "<p>" . elgg_echo('tasks:this:moreinfo', array($link)) . "</p>";
    }
    return $values;
}
Example #23
0
/**
 * Load all the REQUEST variables into the sticky form cache
 *
 * Call this from an action when you want all your submitted variables
 * available if the submission fails validation and is sent back to the form
 *
 * @param string $form_name Name of the sticky form
 *
 * @return void
 * @link http://docs.elgg.org/Tutorials/UI/StickyForms
 * @since 1.8.0
 */
function elgg_make_sticky_form($form_name)
{
    elgg_clear_sticky_form($form_name);
    if (!isset($_SESSION['sticky_forms'])) {
        $_SESSION['sticky_forms'] = array();
    }
    $_SESSION['sticky_forms'][$form_name] = array();
    foreach ($_REQUEST as $key => $var) {
        // will go through XSS filtering on the get function
        $_SESSION['sticky_forms'][$form_name][$key] = $var;
    }
}
/**
 * Pull together blog variables for the save form
 *
 * @param ElggBlog       $post
 * @param ElggAnnotation $revision
 * @return array
 */
function blog_prepare_form_vars($post = NULL, $revision = NULL)
{
    // input names => defaults
    $values = array('title' => NULL, 'description' => NULL, 'status' => 'published', 'access_id' => ACCESS_DEFAULT, 'comments_on' => 'On', 'excerpt' => NULL, 'tags' => NULL, 'container_guid' => NULL, 'guid' => NULL, 'draft_warning' => '');
    if ($post) {
        foreach (array_keys($values) as $field) {
            if (isset($post->{$field})) {
                $values[$field] = $post->{$field};
            }
        }
    }
    if (elgg_is_sticky_form('blog')) {
        $sticky_values = elgg_get_sticky_values('blog');
        foreach ($sticky_values as $key => $value) {
            $values[$key] = $value;
        }
    }
    elgg_clear_sticky_form('blog');
    if (!$post) {
        return $values;
    }
    // load the revision annotation if requested
    if ($revision instanceof ElggAnnotation && $revision->entity_guid == $post->getGUID()) {
        $values['revision'] = $revision;
        $values['description'] = $revision->value;
    }
    // display a notice if there's an autosaved annotation
    // and we're not editing it.
    if ($auto_save_annotations = $post->getAnnotations('blog_auto_save', 1)) {
        $auto_save = $auto_save_annotations[0];
    } else {
        $auto_save == FALSE;
    }
    if ($auto_save && $auto_save->id != $revision->id) {
        $values['draft_warning'] = elgg_echo('blog:messages:warning:draft');
    }
    return $values;
}
Example #25
0
                         $invite_result = group_tools_invite_email($group, $email, $text, $resend);
                         if ($invite_result === true) {
                             $invited++;
                         } elseif ($invite_result === null) {
                             $already_invited++;
                         }
                     }
                 }
             }
         }
     }
     // restore hidden users
     access_show_hidden_entities($hidden);
     // which message to show
     if (!empty($invited) || !empty($join)) {
         elgg_clear_sticky_form('group_invite');
         if (!$adding) {
             system_message(elgg_echo("group_tools:action:invite:success:invite", array($invited, $already_invited, $member)));
         } else {
             system_message(elgg_echo("group_tools:action:invite:success:add", array($join, $already_invited, $member)));
         }
     } else {
         if (!$adding) {
             register_error(elgg_echo("group_tools:action:invite:error:invite", array($already_invited, $member)));
         } else {
             register_error(elgg_echo("group_tools:action:invite:error:add", array($already_invited, $member)));
         }
     }
 } else {
     register_error(elgg_echo("group_tools:action:error:edit"));
 }
Example #26
0
if (elgg_get_plugin_setting('edit_profile_mode', 'profiles_go') == 'tabbed') {
    $tabbed = true;
}
$result = '';
// profile icon
$profile_icon = elgg_get_plugin_setting('profile_icon_on_register', 'profiles_go');
if ($profile_icon == 'yes' || $profile_icon == 'optional') {
    $result .= elgg_view('input/profile_icon');
}
$categorized_fields = profiles_go_get_categorized_fields(null, true, true);
$fields = $categorized_fields['fields'];
$cats = $categorized_fields['categories'];
if (elgg_is_sticky_form('profiles_go_register')) {
    $sticky_values = elgg_get_sticky_values('profiles_go_register');
    extract($sticky_values);
    elgg_clear_sticky_form('profiles_go_register');
}
if (empty($custom_profile_fields_custom_profile_type)) {
    $custom_profile_fields_custom_profile_type = elgg_get_plugin_setting('default_profile_type', 'profiles_go');
}
if (elgg_get_plugin_setting('profile_type_selection', 'profiles_go') !== 'admin') {
    $result .= elgg_view('profiles_go/register/profile_type_selection', ['value' => $custom_profile_fields_custom_profile_type]);
} else {
    $result .= elgg_view('input/hidden', ['name' => 'custom_profile_fields_custom_profile_type', 'value' => $custom_profile_fields_custom_profile_type]);
}
if (!empty($fields)) {
    $tabbed_cat_titles = '';
    $tabbed_cat_content = '';
    $tab_selected = false;
    foreach ($cats as $cat_guid => $cat) {
        $linked_profile_types = array(0);
Example #27
0
    $topic->subtype = 'groupforumtopic';
} else {
    // load original file object
    $topic = new ElggObject($guid);
    if (!$topic || !$topic->canEdit()) {
        register_error(elgg_echo('discussion:topic:notfound'));
        forward(REFERER);
    }
}
$topic->title = $title;
$topic->description = $desc;
$topic->status = $status;
$topic->access_id = $access_id;
$topic->container_guid = $container_guid;
$tags = explode(",", $tags);
$topic->tags = $tags;
$result = $topic->save();
if (!$result) {
    register_error(elgg_echo('discussion:error:notsaved'));
    forward(REFERER);
}
// topic saved so clear sticky form
elgg_clear_sticky_form('topic');
// handle results differently for new topics and topic edits
if ($new_topic) {
    system_message(elgg_echo('discussion:topic:created'));
    add_to_river('river/object/groupforumtopic/create', 'create', elgg_get_logged_in_user_guid(), $topic->guid);
} else {
    system_message(elgg_echo('discussion:topic:updated'));
}
forward($topic->getURL());
Example #28
0
    register_error(elgg_echo('questions:action:answer:save:error:body', [$container_guid, $description]));
    forward(REFERER);
}
if ($adding && !can_write_to_container(0, $container_guid, 'object', 'answer')) {
    register_error(elgg_echo('questions:action:answer:save:error:container'));
    forward(REFERER);
}
$question = get_entity($container_guid);
if (empty($question) || !$question instanceof ElggQuestion) {
    register_error(elgg_echo('ClassException:ClassnameNotClass', [$container_guid, elgg_echo('item:object:question')]));
    forward(REFERER);
}
if ($question->getStatus() != 'open') {
    elgg_clear_sticky_form('answer');
    register_error(elgg_echo('questions:action:answer:save:error:question_closed'));
    forward(REFERER);
}
$answer->description = $description;
$answer->access_id = $question->access_id;
$answer->container_guid = $container_guid;
try {
    $answer->save();
    if ($adding) {
        elgg_create_river_item(['view' => 'river/object/answer/create', 'action_type' => 'create', 'subject_guid' => elgg_get_logged_in_user_guid(), 'object_guid' => $answer->getGUID(), 'access_id' => $answer->access_id]);
    }
} catch (Exception $e) {
    register_error(elgg_echo('questions:action:answer:save:error:save'));
    register_error($e->getMessage());
}
elgg_clear_sticky_form('answer');
forward(get_input('forward', $answer->getURL()));
Example #29
0
<?php

/**
 * Elgg No Name plugin
 *
 * Delete 'Display Name' field from register and useradd forms
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author pianist
 * @URL http://elgghacks.com
 * @copyright http://o.wzm.me/totemz/v/2015/elgg-hacks
 */
$name = $username = $email = $password = $password2 = $admin = '';
if (elgg_is_sticky_form('useradd')) {
    extract(elgg_get_sticky_values('useradd'));
    elgg_clear_sticky_form('useradd');
    if (is_array($admin)) {
        $admin = $admin[0];
    }
}
?>
<div>
	<label><?php 
echo elgg_echo('username');
?>
</label><br />
	<?php 
echo elgg_view('input/text', array('name' => 'username', 'value' => $username));
?>
</div>
<div>
	<label><?php 
Example #30
0
        if ($page_guid == $tree_page->guid) {
            $previous_parent = $page->parent_guid;
            $children = elgg_get_entities_from_metadata(array('metadata_name' => 'parent_guid', 'metadata_value' => $page->getGUID()));
            if ($children) {
                foreach ($children as $child) {
                    $child->parent_guid = $previous_parent;
                }
            }
        }
    }
    $page->parent_guid = $parent_guid;
}
if ($page->save()) {
    //check in the page becaused the user just saved it
    if ($page->deleteMetadata("checkedOut")) {
        system_message(elgg_echo('pages:checked_in'));
    } else {
        system_message('Page could not be checked in. It is still locked for editing');
    }
    elgg_clear_sticky_form('page');
    // Now save description as an annotation
    $page->annotate('page', $page->description, $page->access_id);
    system_message(elgg_echo('pages:saved'));
    if ($new_page) {
        add_to_river('river/object/page/create', 'create', elgg_get_logged_in_user_guid(), $page->guid);
    }
    forward($page->getURL());
} else {
    register_error(elgg_echo('pages:error:notsaved'));
    forward(REFERER);
}