Пример #1
0
 public static function is_allowed($pod_name, $cap, &$debug = null)
 {
     if (core_utilities::isAdministrator(wp_get_current_user())) {
         if ($debug != NULL) {
             $debug .= "<pre>isAdministrator</pre>";
         }
         return TRUE;
     }
     //sys_admin
     $user = wp_get_current_user();
     if ($debug != NULL) {
         $debug .= "<pre>" . var_export($user, TRUE) . "</pre>";
     }
     if (!empty($user->roles) && is_array($user->roles)) {
         if (in_array("sys_admin", $user->roles)) {
             return TRUE;
         }
     }
     if ($debug != NULL) {
         $debug .= "<h4>CAP</h4><pre>" . var_export($cap, TRUE) . "</pre>";
     }
     if (is_array($cap)) {
         foreach ($cap as $c) {
             if (current_user_can("pods_{$c}" . "_{$pod_name}")) {
                 if ($debug != NULL) {
                     $debug .= "<pre>" . var_export($c, TRUE) . "</pre>";
                 }
                 return TRUE;
             }
         }
     } elseif (current_user_can("pods_{$cap}" . "_{$pod_name}")) {
         return TRUE;
     }
     return FALSE;
 }
Пример #2
0
function custom_login_css()
{
    echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/styles/css/admin.css" />';
    core_utilities::init_dms(TRUE);
    global $jomiz_dms_settings;
    if ($jomiz_dms_settings->login_logo != "") {
        echo "<style type='text/css'>\n\t\t\t.login h1 a\n\t\t\t{\n\t\t\t\t  background-image:  url('" . $jomiz_dms_settings->login_logo . "') !important;\n\t\t\t\t    background-size: auto;\n\t\t\t}\n\t\t</style>";
    }
}
Пример #3
0
 public static function init_dms($skip_login = FALSE)
 {
     // Protect By Login
     if (!is_user_logged_in() && $skip_login == FALSE) {
         wp_redirect(core_utilities::get_login_url());
         exit;
         return;
     }
     global $current_user;
     if ($current_user == null) {
         get_currentuserinfo();
     }
     global $jomiz_dms_settings;
     if ($jomiz_dms_settings == null) {
         $jomiz_dms_settings = new dms_settings();
         $jomiz_dms_settings->init();
     }
     global $jomiz_dms_workflow;
     if ($jomiz_dms_workflow == null) {
         $jomiz_dms_workflow = new dms_workflow();
         $jomiz_dms_workflow->init();
     }
 }
Пример #4
0
$return_url = isset($_GET['return-to']) ? urldecode($_GET['return-to']) : get_home_url();
//dms_debug::add_database_message("1", "Action Exectiopn", "ACTION API PAGE");
if ($action_id < 0 || $action_id == "") {
    echo core_utilities::get_error_message("No Action");
    return;
}
//dms_debug::add_database_message("2", "Action Exectiopn", "ACTION API PAGE");
if ($record_id < 0 || $record_id == "") {
    echo core_utilities::get_error_message("No Record");
    return;
}
//dms_debug::add_database_message("3", "Action Exectiopn", "ACTION API PAGE");
$action_on_pod = pods("jomiz_dms_actions", array('where' => "t.id = {$action_id}"));
//dms_debug::add_database_message(var_export($action_on_pod, TRUE), "Action Exectiopn", "ACTION API PAGE");
if ($action_on_pod->total() == 0) {
    echo core_utilities::get_error_message("The Action Is Not Registered");
    return;
}
if (dms_data::is_record_sealed($action_on_pod->field("pod_name"), $record_id)) {
    // Record Is Sealed
    //wp_redirect($return_url);
    //return;
}
$arguments = array();
$arguments["record_id"] = $record_id;
$arguments["podname"] = $action_on_pod->field("pod_name");
$arguments["built_in_action"] = "";
$arguments["built_in_parameters"] = "";
$arguments["custom_php"] = $action_on_pod->field("custom_php");
$arguments["stop_on_error_messages"] = $action_on_pod->field("stop_on_error_messages");
$action = new dms_action($arguments);
Пример #5
0
<?php

core_utilities::init_dms();
global $current_user;
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US" class="no-js">
<head>
	 <meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title><?php 
global $page_title;
if ($page_title != "") {
    echo "{$page_title} | ";
}
bloginfo('name');
?>
</title> 
    <link href="<?php 
echo get_template_directory_uri();
?>
/style.css" media="screen" rel="stylesheet">
    <link rel="stylesheet/less" type="text/css" href="<?php 
echo get_template_directory_uri();
?>
/styles/css/styles.less" />
    <script src="<?php 
echo get_template_directory_uri();
?>
Пример #6
0
 public static function upload_attachment()
 {
     if (!isset($_FILES['attachment_input_file'])) {
         return "No File!";
     }
     $result = core_utilities::insert_attachment('attachment_input_file');
     if ($result['message'] != "ok") {
         return $result['message'];
     }
     $data = array();
     $data['pod_name'] = $_POST['attachment_input_podname'];
     $data['record_id'] = $_POST['attachment_input_record_id'];
     $data['file'] = $result['attachment_id'];
     $data['name'] = $_POST['attachment_input_file_name'];
     $attachment_id = $data['file'];
     settype($attachment_id, "integer");
     if ($data['name'] == '') {
         $file_meta = get_attached_file($attachment_id);
         if (is_array($file_meta) && isset($file_meta['file'])) {
             $data['name'] = pathinfo($file_meta['file']);
             $data['name'] = $data['name']['basename'];
         } elseif (is_string($file_meta)) {
             $data['name'] = pathinfo($file_meta);
             $data['name'] = $data['name']['basename'];
         }
     }
     return pods("jomiz_dms_attachements")->add($data);
 }
Пример #7
0
 public static function build_toolbar($pod_name, $pod_label, $use_dialog = false, $url_params = null, $use_filter = false)
 {
     $toolbar = "";
     $current_page_url = urlencode(core_utilities::get_current_page_url());
     if (dms_security::is_allowed($pod_name, "add")) {
         $toolbar .= "<a class='btn btn-default' href='" . pods_related::get_pod_url($pod_name, "add", -1, $use_dialog, $current_page_url, $url_params) . "' title='Add {$pod_label}'><span class='glyphicon glyphicon-plus'></span></a>";
     }
     if ($use_filter) {
         $toolbar .= "<a onclick='hide_show_filter()' id='filter-button' class='btn btn-default' href='#' title='Search in {$pod_label}'><span class='glyphicon glyphicon-filter'></span></a>";
     }
     if ($toolbar != "") {
         $toolbar = "<div class='btn-group' role='group' aria-label='...'>{$toolbar}</div>";
     }
     return $toolbar;
 }
Пример #8
0
<?php

/*
Template Name: List Pods
*/
$podname = isset($_GET['type']) ? $_GET['type'] : "";
$limit = isset($_GET['size']) ? $_GET['size'] : core_utilities::get_default_page_size();
$offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
$offset = $offset * $limit;
if ($podname == '') {
    echo core_utilities::get_error_message("No Type Avaliable");
    return;
}
$PodsAPI = pods_api();
$pods_info = $PodsAPI->load_pod(array('name' => $podname));
core_utilities::set_page_title("Listing - " . $pods_info['label']);
get_header();
// CONTENT GOES HERE
?>
<div class="row">
	<div class="col-xs-12">
		<div class="page-title-row">
			<div class="row">
				<div class="col-xs-12 col-sm-9"><h1 class="page-title">Listing - <?php 
echo $pods_info['label'];
?>
</h1></div>
				<div class="col-xs-12 col-sm-3 text-right toolbar-top">
					<?php 
echo pods_related::build_toolbar($podname, $pods_info['label'], false, null, $pods_info['options']['ui_filters'] != null);
?>
Пример #9
0
</h1>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="row">
	<div class="col-xs-12 delete-message <?php 
echo $notification_css_class;
?>
">
		<?php 
echo $notification_message;
?>
	</div>
</div>
<div class="row">
	<div class="col-xs-12 delete-options text-center">
		<?php 
if ($record_sealed && dms_security::is_allowed($podname, "delete_sealed") || !$record_sealed) {
    echo "<a title='Delete' href='" . core_utilities::get_current_page_url() . "&confirm-delete=1' class='btn btn-danger'>Delete</a>";
}
?>
		<a title="Cancel" href="<?php 
echo $return_url;
?>
" class="btn btn-default">Cancel</a>
	</div>
</div>
<?php 
get_footer("dialog");
Пример #10
0
$header_prefix = "Edit";
$operation_type = "edit";
if ($id == -1) {
    $header_prefix = "Add";
    $operation_type = "add";
}
// Get The Data Of The Current Pod + Record Id
$record_author = -1;
if ($id == -1) {
    $mypod = pods($podname);
} else {
    $mypod = pods($podname, $id);
    $record_author = $mypod->field("author");
}
// Set Page Title
core_utilities::set_page_title($header_prefix . " " . $pods_info['label']);
$use_tabs = FALSE;
// Get Related Pods From The Settings
$related_pods = pods("pods_gui_related_pods", array("where" => "t.name = '{$podname}'", "orderby" => "display_order"));
$ui_param = array();
$save_txt = "Save";
$after_save_url = $return_url;
$same_page_url = pods_related::get_pod_url($podname, "edit", $id, $use_dialog, $return_url);
// Operation Settings
$operation_settings_pod = pods("jomiz_dms_gui_settings", array("where" => "t.pod_name = '{$podname}' AND (operation='add' OR operation='edit')"));
$operation_settings = null;
$extra_js = "";
if ($operation_settings_pod->total() > 0) {
    $operation_settings = json_decode($operation_settings_pod->field("settings"));
    $extra_js = $operation_settings_pod->field("extra_javascript");
}
Пример #11
0
 public static function gui_filter_pod()
 {
     $result = "";
     $podname = isset($_GET['podname']) ? $_GET['podname'] : "";
     if ($podname == "") {
         $result = "Op. gui_filter_pod -> Error: No Pod.";
         return $result;
     }
     $PodsAPI = pods_api();
     $pods_info = null;
     try {
         $pods_info = $PodsAPI->load_pod(array('name' => $podname));
     } catch (Exception $e) {
         $result = "Op. gui_filter_pod -> Error: Pod Not Exists.";
         return $result;
     }
     $offset = 0;
     $limit = core_utilities::get_default_page_size();
     $params = array();
     $where = array();
     foreach ($_GET as $key => $value) {
         if ($key == "podname" || $key == "op" || strpos($key, "order-") !== FALSE) {
             continue;
         }
         $field = str_replace("to_control_", "", $key);
         $field = str_replace("control_", "", $field);
         $result .= "<br/>Op. gui_filter_pod -> Debug: " . var_export($key, TRUE);
         $result .= "<br/>Op. gui_filter_pod -> Debug: " . var_export($value, TRUE);
         $result .= "<br/>Op. gui_filter_pod -> Debug: " . var_export($field, TRUE);
         $result .= "<br/>Op. gui_filter_pod -> Debug: " . var_export($pods_info['fields'][$field], TRUE);
         switch ($pods_info['fields'][$field]['type']) {
             case 'text':
             case 'website':
             case 'phone':
             case 'email':
             case 'password':
             case 'paragraph':
             case 'wysiwyg':
             case 'code':
             case 'slug':
                 // Text Field
                 $where[] = "t.{$field} like '%{$value}%'";
                 break;
             case 'pick':
                 if ($field == 'author') {
                     $where[] = "{$field}.display_name like '%{$value}%'";
                 } elseif ($pods_info['fields'][$field]['pick_object'] == "custom-simple") {
                     $where[] = "{$field} = '{$value}'";
                 } else {
                     $where[] = "{$field}.name like '%{$value}%'";
                 }
                 break;
             case 'number':
             case 'currency':
                 // Numaric Fields
                 $comparison_operation = ">=";
                 if (strpos($key, 'to_control_') !== false) {
                     $comparison_operation = "<=";
                 }
                 $where[] = "t.{$field} {$comparison_operation} {$value}";
                 break;
             case 'datetime':
             case 'date':
             case 'time':
                 // Date/Time Field
                 $comparison_operation = ">=";
                 if (strpos($key, 'to_control_') !== false) {
                     $comparison_operation = "<=";
                 }
                 $where[] = "t.{$field} {$comparison_operation} '{$value}'";
                 break;
             default:
                 $result .= "Op. gui_filter_pod -> Error: Not Supported Field Type.";
                 return $result;
         }
     }
     $params["where"] = implode(" AND ", $where);
     // Handle Order By
     if (isset($_GET['order-orderby']) && $_GET['order-orderby'] != "") {
         $orderby = $_GET['order-orderby'];
         if (isset($_GET['order-type']) && $_GET['order-type'] != "") {
             $orderby .= "|" . $_GET['order-type'];
         } else {
             $orderby .= "|ASC";
         }
         $params["orderby"] = $orderby;
     }
     $result = pods_related::build_table($pods_info, $offset, $limit, $params, FALSE, null, TRUE, TRUE);
     return $result;
 }