Example #1
0
function AdminListView($admin)
{
    echo View::show_flash();
    if ($admin->list->yes_search == 1) {
        $admin->list->search_by_url();
        $select = new SelectForm('field_search', $_GET['field_search']);
        //$select->arr_select=$admin->list->load_fields_showed($admin->list->arr_fields_no_search);
        foreach ($admin->list->arr_fields_search as $field) {
            $select->arr_select[$field] = Webmodel::$model[$admin->model_name]->forms[$field]->label;
        }
        if ($_GET['field_search'] == '') {
            $select->default_value = $admin->list->default_field_search;
        }
        $select_order = new SelectForm('order', $_GET['order']);
        $select_order->arr_select = array(0 => I18n::lang('common', 'asc', 'Ascendent'), 1 => I18n::lang('common', 'desc', 'Descendent'));
        $search = new BaseForm('search', $_GET['search']);
        ?>
        <div class="cont search">
            <form method="get" action="<?php 
        echo $admin->url;
        ?>
">
                <?php 
        echo I18n::lang('common', 'search', 'Search');
        ?>
                <?php 
        echo $search->form();
        ?>
                <?php 
        echo $select->form();
        echo $select_order->form();
        ?>
                <input type="submit" value="<?php 
        echo I18n::lang('common', 'search', 'Search');
        ?>
" />
                <input type="reset" value="<?php 
        echo I18n::lang('common', 'reset', 'Reset');
        ?>
" onclick="javascript:location.href='<?php 
        echo $admin->url;
        ?>
';"/>
            </form>
        </div>
        <?php 
    }
    if (!$admin->no_insert) {
        ?>
        <p><a href="<?php 
        echo Routes::add_get_parameters($admin->url, array('op_admin' => 1));
        ?>
"><?php 
        echo $admin->text_add_item;
        ?>
</a></p>
    <?php 
    }
    $admin->list->show();
}
Example #2
0
function ParentLinksView($arr_hierarchy, $url_fancy, $idfield, $arr_parameters = array(), $last_link = 0, $name_home = 'Principal')
{
    $arr_hierarchy[0]['name'] = $name_home;
    $arr_final = array();
    $c = count($arr_hierarchy) - 1;
    for ($x = 0; $x < $c; $x++) {
        $arr_id =& $arr_hierarchy[$x];
        $arr_tmp_param = $arr_parameters;
        $arr_tmp_param[$idfield] = $arr_id['id'];
        //$arr_tmp_param[]=slugify($arr_id['name']);
        $arr_final[$x] = '<a href="' . Routes::add_get_parameters($url_fancy, $arr_tmp_param) . '">' . $arr_id['name'] . '</a>';
    }
    switch ($last_link) {
        default:
            $arr_final[$x] = $arr_hierarchy[$x]['name'];
            break;
        case 1:
            $arr_tmp_param = $arr_parameters;
            $arr_tmp_param[$idfield] = $arr_hierarchy[$x]['id'];
            $arr_tmp_param[] = Utils::slugify($arr_hierarchy[$x]['name']);
            $arr_final[$x] = '<a href="' . Routes::add_get_parameters($url_fancy, $arr_tmp_param) . '">' . $arr_hierarchy[$x]['name'] . '</a>';
            break;
    }
    echo '<p>' . implode(' &gt; ', $arr_final);
}
Example #3
0
 /**
  * Method for recovery the password using a token. The data is obtain from $_GET['token_recovery']
  */
 public function recovery_password()
 {
     settype($_GET['token_recovery'], 'string');
     $_GET['token_recovery'] = trim($this->model_login->check_where_sql($this->field_recovery, $_GET['token_recovery']));
     if ($_GET['token_recovery'] == '') {
         settype($_POST['email'], 'string');
         $email = Utils::form_text($_POST['email']);
         $this->model_login->set_conditions('where ' . $this->field_mail . '="' . $email . '"');
         $this->model_login->reset_conditions = false;
         $query = $this->model_login->select(array($this->model_login->idmodel, $this->field_name, $this->field_mail));
         $this->model_login->reset_conditions = true;
         list($iduser_recovery, $nick, $email) = $this->model_login->fetch_row($query);
         settype($iduser_recovery, 'integer');
         if ($iduser_recovery > 0) {
             $email = @Utils::form_text($_POST['email']);
             $query = $this->model_login->select(array($this->model_login->idmodel, $this->field_name, $this->field_mail));
             list($iduser_recovery, $nick, $email) = $this->model_login->fetch_row($query);
             settype($iduser_recovery, 'integer');
             //Create token recovery...
             $token_recovery = hash($this->method_crypt, Utils::get_token());
             $this->model_login->reset_require();
             $this->model_login->set_conditions('where ' . $this->model_login->idmodel . '=' . $iduser_recovery);
             $query = $this->model_login->update(array($this->field_recovery => $token_recovery));
             //$query=$model['recovery_password']->insert(array('iduser' => $iduser_recovery, 'token_recovery' => sha1($token_recovery), 'date_token' => TODAY) );
             //Send email
             $url_check_token = Routes::add_get_parameters($this->url_recovery_send, array('token_recovery' => $token_recovery));
             $topic_email = I18n::lang('users', 'lost_name', 'You requested a new password');
             $body_email = I18n::lang('users', 'hello_lost_pass', 'Hello, you have requested a new password.') . "\n\n" . I18n::lang('users', 'explain_code_pass', 'You have requested a new password. Copy and paste the following url into your browser, and a new password will be generated for you. If you did not request this operation, ignore this message.') . "\n\n" . I18n::lang('users', 'copy_paste_code', 'Copy and paste the following url') . ': ' . $url_check_token . "\n\n" . I18n::lang('common', 'thanks', 'Thanks');
             if (Emailer::send_mail($this->sender, $email, $topic_email, $body_email)) {
                 echo '<p>' . I18n::lang('users', 'explain_email_code_pass', 'You have requested a new password. Copy and paste the following url into your browser, and a new password will be generated for you. If you did not request this operation, ignore this message.') . '</p>';
             } else {
                 echo '<p>' . I18n::lang('users', 'cannot_email_code_pass', 'We can not send to your email the instructions to change your password. Please contact the administrator of this site to solve the problem.') . '</p>';
             }
         } else {
             echo "<p>" . I18n::lang('users', 'error_db_pass', 'Error, mail format is wrong') . '</p>';
             echo "<p><a href=\"" . $this->url_recovery . "\"><b>" . I18n::lang('common', 'go_back', 'Go back') . "</b></a></p>";
         }
     } else {
         $this->model_login->set_conditions('where ' . $this->field_recovery . '="' . $_GET['token_recovery'] . '"');
         $query = $this->model_login->select(array($this->model_login->idmodel, $this->field_name, $this->field_mail));
         list($iduser_recovery, $nick, $email) = $this->model_login->fetch_row($query);
         settype($iduser_recovery, 'integer');
         if ($iduser_recovery > 0) {
             $password = Utils::generate_random_password();
             $topic_email = I18n::lang('users', 'success_change_password', 'The password was changed successfully.');
             $body_email = I18n::lang('users', 'hello_lost_pass_successful', 'Hello, we have changed your password and is shown below. With these data should be back online in the system.') . "\n\n" . I18n::lang('users', 'user_data', 'User\'s data') . "\n\n" . I18n::lang('users', 'user', 'User') . " : {$nick}" . "\n\n" . I18n::lang('common', 'email', 'Email') . " : {$email}" . "\n\n" . I18n::lang('users', 'new_pass', 'New password') . " : {$password}" . "\n\n" . I18n::lang('common', 'thanks', 'Thanks');
             if ($email !== "") {
                 //$query=$model['recovery_password']->delete('where '.$this->model_login->idmodel.'='.$iduser_recovery);
                 $this->model_login->reset_require();
                 $query = $this->model_login->update(array($this->field_password => $password, $this->field_recovery => ''), 'where ' . $this->model_login->idmodel . '=' . $iduser_recovery);
                 if (Emailer::send_mail($this->sender, $email, $topic_email, $body_email)) {
                     echo "<p>" . I18n::lang('users', 'success_change_password', 'The password was changed successfully.') . '</p>';
                     echo "<p>" . I18n::lang('users', 'success_change_password_explain', 'We have sended to your email, the new password.') . '</p>';
                 } else {
                     echo "<p>" . I18n::lang('users', 'success_change_password', 'The password was changed successfully.') . '</p>';
                     echo "<p>" . I18n::lang('users', 'error_sending_mail_change_password', 'We can not send your new password to your email at this time, we are showing your user data in plain text. For added security, change your password once achieved identified in the system again.') . '</p>';
                     echo '<pre>';
                     echo $body_email;
                     echo '</pre>';
                 }
             } else {
                 echo "<p>" . I18n::lang('users', 'error_db_pass', 'Error, mail format is wrong') . '</p>';
             }
         } else {
             echo "<p>" . I18n::lang('users', 'error_token_pass', 'Error: incorrect code used to change a password.') . '</p>';
         }
         echo "<p><a href=\"" . $this->url_login . "</b></a></p>";
     }
 }
Example #4
0
 public function show_config()
 {
     settype($_GET['op_admin'], 'integer');
     $action = Routes::add_get_parameters($this->url, array('op_admin' => 1));
     switch ($_GET['op_admin']) {
         default:
             $post = $this->model->select_a_row_where($this->arr_fields_edit, true);
             $this->form($post, $action);
             break;
         case 1:
             $c = $this->model->select_count();
             if ($c > 0) {
                 $post = $this->model->select_a_row_where([$this->model->idmodel], true);
                 $_GET[$this->model->idmodel] = $post[$this->model->idmodel];
                 $this->update_model($action);
             } else {
                 $this->insert_model($action);
             }
             break;
     }
 }
Example #5
0
 public static function NoDeleteOptionsListModel($url_options, $model_name, $id)
 {
     $url_options_edit = Routes::add_get_parameters($url_options, array('op_admin' => 2, Webmodel::$model[$model_name]->idmodel => $id));
     $arr_options = array('<a href="' . $url_options_edit . '">' . I18n::lang('common', 'edit', 'Edit') . '</a>');
     return $arr_options;
 }